Add a file using api

From @aniket-kumar on Wed Jun 08 2016 07:46:21 GMT+0000 (UTC)

I want to create a webpage in which user will upload a file and that file will be uploaded on ipfs and i will get the hash of file internally. I think i can do this using the apis of ipfs but i didn’t get any particular documentation of ipfs apis. Tell me, How can i solve this purpose?


Copied from original issue: https://github.com/ipfs/faq/issues/131

From @aniket-kumar on Thu Jun 09 2016 07:29:37 GMT+0000 (UTC)

@Harshetha I am not able to see your comment. I think your response can help a lot to solve this issue. Thanks in advance

From @harshetha on Thu Jun 09 2016 13:48:53 GMT+0000 (UTC)

I am working on a web scenario where I have to upload a file into ipfs and
then retrieve the document hash. I am working off of this code I have
linked but it is not fully functional, just a general idea of how to call
functions from the ipfs api using Node.js.

Let me know if you find something further and I will do the same

On Thu, Jun 9, 2016 at 3:29 AM, aniket-kumar notifications@github.com
wrote:

@Harshetha harshetha (Harshetha Sundar) · GitHub I am not able to see your
comment. I think your help can help a lot to solve this issue. Thanks in
advance

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Add a file using api · Issue #131 · ipfs-inactive/faq · GitHub, or mute
the thread
GitHub · Where software is built
.

From @aniket-kumar on Thu Jun 09 2016 14:14:30 GMT+0000 (UTC)

I have tried multiple approaches found from anywhere but none of them is working to upload a file. Yeah, i come to learn how to upload text only. I don’t know if any api of ipfs is made for this purpose.

From @harshetha on Thu Jun 09 2016 19:20:04 GMT+0000 (UTC)

Can I see how you uploaded text? Maybe I can add some commands and combine
my knowledge to figure out how to upload a file.

On Thu, Jun 9, 2016 at 10:14 AM, aniket-kumar notifications@github.com
wrote:

I have tried multiple approaches found from anywhere but none of them is
working to upload a file. Yeah, i come to learn how to upload text only. I
don’t know if any api of ipfs is made for this purpose.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Add a file using api · Issue #131 · ipfs-inactive/faq · GitHub, or mute
the thread
GitHub · Where software is built
.

From @aniket-kumar on Fri Jun 10 2016 06:14:48 GMT+0000 (UTC)

I just followed this :

let me know about any progress… :slight_smile:

From @harshetha on Fri Jun 10 2016 13:55:04 GMT+0000 (UTC)

I have tried this before but it did not work for me, can I see your code
and file structure?

Thanks
Harshetha

On Fri, Jun 10, 2016 at 2:14 AM, aniket-kumar notifications@github.com
wrote:

I just followed this :
ipfs-js - npm

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Add a file using api · Issue #131 · ipfs-inactive/faq · GitHub, or mute
the thread
GitHub · Where software is built
.

From @harshetha on Fri Jun 10 2016 14:03:24 GMT+0000 (UTC)

I also think I know how to integrate the file upload with ipfs but having a
few issues

On Fri, Jun 10, 2016 at 9:55 AM, Harshetha Sundar <
harshetha.sundar@gmail.com> wrote:

I have tried this before but it did not work for me, can I see your code
and file structure?

Thanks
Harshetha

On Fri, Jun 10, 2016 at 2:14 AM, aniket-kumar notifications@github.com
wrote:

I just followed this :
ipfs-js - npm

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Add a file using api · Issue #131 · ipfs-inactive/faq · GitHub, or mute
the thread
GitHub · Where software is built
.

From @aniket-kumar on Fri Jun 10 2016 14:11:53 GMT+0000 (UTC)

It was also not working on my system but when i uploaded it to ipfs and executed it from ipfs then it worked for me. Try that. Follow all the steps given in that link till 4th one.

From @aniket-kumar on Mon Jun 13 2016 11:33:03 GMT+0000 (UTC)

@harshetha any progress?

From @harshetha on Mon Jun 13 2016 14:08:34 GMT+0000 (UTC)

No, the issue is that the files.add function is not yet implemented in the
index.js or the load-commands.js (these files are called in the ipfs api),
we either need to write our own function or find someone’s fork that
already has it.

On Mon, Jun 13, 2016 at 7:33 AM, aniket-kumar notifications@github.com
wrote:

@harshetha harshetha (Harshetha Sundar) · GitHub any progress?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Add a file using api · Issue #131 · ipfs-inactive/faq · GitHub, or mute
the thread
GitHub · Where software is built
.

From @aniket-kumar on Mon Jun 13 2016 14:09:41 GMT+0000 (UTC)

yeah, you are right. I was also thinking same.

From @harshetha on Mon Jun 13 2016 15:06:52 GMT+0000 (UTC)

I am also trying out this

On Mon, Jun 13, 2016 at 10:09 AM, aniket-kumar notifications@github.com
wrote:

yeah, you are right. I was also thinking same.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
Add a file using api · Issue #131 · ipfs-inactive/faq · GitHub, or mute
the thread
GitHub · Where software is built
.

From @aniket-kumar on Tue Jun 14 2016 11:30:07 GMT+0000 (UTC)

ok, let me know about any progress…go ahead

From @RichardLitt on Tue Jun 14 2016 11:33:49 GMT+0000 (UTC)

@diasdavid Can you answer this?

From @diasdavid on Tue Jun 14 2016 21:59:51 GMT+0000 (UTC)

You can upload a file to IPFS using the js-ipfs-api(HTTP Client Library, works with Go or JS IPFS nodes) or js-ipfs (Full node in JS) using the interface defined here https://github.com/ipfs/interface-ipfs-core#files

Try first using https://github.com/ipfs/js-ipfs-api and the go-ipfs daemon and let me know of your results. Note that you will have to set the CORS headers this way https://github.com/ipfs/js-ipfs-api#cors

From @aniket-kumar on Wed Jun 15 2016 05:36:16 GMT+0000 (UTC)

@diasdavid i tried this js-ipfs-api. It is working fine for ipfs.id but when i tried to use ipfs.add(“string”).then(callback) , it showed the error : Uncaught TypeError: ipfs.add is not a function

From @diasdavid on Wed Jun 15 2016 06:04:43 GMT+0000 (UTC)

@aniket-kumar, try with ipfs.files.add

From @aniket-kumar on Wed Jun 15 2016 06:16:17 GMT+0000 (UTC)

@diasdavid now new error : Uncaught TypeError: cb is not a function in add.js
I am trying to add the string as ipfs.files.add(“hey”) . I also tried it with hex and binary format of string. It is giving the same error.

From @aniket-kumar on Thu Jun 23 2016 05:22:49 GMT+0000 (UTC)

@harshetha @RichardLitt @diasdavid any new findings?