Skip to content

Commit

Permalink
fix: ipfs path parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvolek committed Jul 19, 2021
1 parent 907b2eb commit c92af3a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.9.3]

### Fixed

- ipfs path parameter

## [0.9.2]

### Fixed
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,10 @@ const IPFS = new BlockFrostIPFS({
});

try {
const stream = fs.createReadStream(`${__dirname}/img.svg`);
const added = await IPFS.add(stream);

const added = await IPFS.add(`${__dirname}/img.svg`);
console.log('added', added);

const pinned = await IPFS.pin(added.ipfs_hash);

console.log('pinned', pinned);
} catch (err) {
console.log('error', err);
Expand Down
File renamed without changes
1 change: 1 addition & 0 deletions examples/images/cardano.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions examples/ipfs.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { BlockFrostIPFS } from '../src/index';
import fs from 'fs';

async function run() {
const IPFS = new BlockFrostIPFS({
projectId: 'YOUR API KEY HERE', // see: https://blockfrost.io
});

try {
const stream = fs.createReadStream(`${__dirname}/img.svg`);
const added = await IPFS.add(stream);

const added = await IPFS.add(`${__dirname}/images/blockfrost.svg`);
console.log('added', added);

const pinned = await IPFS.pin(added.ipfs_hash);

console.log('pinned', pinned);
} catch (err) {
console.log('error', err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockfrost/blockfrost-js",
"version": "0.9.2",
"version": "0.9.3",
"description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API",
"keywords": [
"blockfrost",
Expand Down
8 changes: 5 additions & 3 deletions src/endpoints/ipfs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { handleError, getPaginationOptions } from '../../utils';
import { PaginationOptions } from '../../types';
import { AddResponse, PinResponse, ListResponse } from '../../types/ipfs';
import FormData from 'form-data';
import { ReadStream } from 'fs';
import fs from 'fs';

export async function add(
this: BlockFrostIPFS,
readStream: ReadStream,
path: string,
): Promise<AddResponse> {
const stream = fs.createReadStream(path);
const data = new FormData();
data.append('file', readStream);

data.append('file', stream);

return new Promise((resolve, reject) => {
this.axiosInstance
Expand Down
4 changes: 1 addition & 3 deletions test/tests/ipfs/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { IPFS } from '../../utils';
import fs from 'fs';

describe('IPFS', () => {
test('flow', async () => {
const stream = fs.createReadStream(
const addedObject = await IPFS.add(
`${__dirname}/../../fixtures/files/img.svg`,
);
const addedObject = await IPFS.add(stream);

expect(addedObject).toMatchObject({
ipfs_hash: 'QmUCXMTcvuJpwHF3gABRr69ceQR2uEG2Fsik9CyWh8MUoQ',
Expand Down

0 comments on commit c92af3a

Please sign in to comment.