Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Create example: uploading binary file via browser form "file upload" #316

Closed
harlantwood opened this issue Jul 6, 2016 · 6 comments
Closed

Comments

@harlantwood
Copy link
Contributor

harlantwood commented Jul 6, 2016

Below are notes from my post to a thread on ipfs-users:

I wrestled with this one for a while, trying to upload images to IPFS from the browser. It's a bit tricky.

Here is a gist of a simplified version of the working solution that I ended up with:

https://gist.github.com/harlantwood/58990ebe47b54e05020a13a45a124dff

This example is in ES6 / React, but all the important stuff should work in other contexts.

Important note: I had to require buffer directly -- using IpfsApi.Buffer did not work for me, maybe because of a version difference, not sure. And yes you need the trailing slash:

Buffer = require('buffer/').Buffer

Otherwise you will get the nodejs built in buffer.

@harlantwood
Copy link
Contributor Author

Could be combined with #315, or could be a separate example.

@harlantwood harlantwood changed the title Example of uploading binary file via browser form "file upload" Create example: uploading binary file via browser form "file upload" Jul 6, 2016
@daviddias
Copy link
Contributor

Hey @harlantwood o/ Would you like to PR the working example for this repo? It would be greatly appreciated :)

@harlantwood
Copy link
Contributor Author

harlantwood commented Nov 12, 2016 via email

@lidel
Copy link
Contributor

lidel commented Feb 26, 2017

@harlantwood any luck? I tried to use upstream browser bundle but it I am stuck due to missing Buffer: #528

Update: Buffer is avaiable after you initialize API instance eg:
const Buffer = window.IpfsApi().Buffer

@harlantwood
Copy link
Contributor Author

Added example in #539.

@daviddias
Copy link
Contributor

Thank you @harlantwood :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants