Is there any other methods to upload a file/files to IPFS through a web browser beside using API port 5001

I binded my IPFS server’s local lan IP to IPFS API through the following commands: ipfs config Addresses.API /ip4/192.168.1.18/tcp/5001. I can upload file through web browser by using the Javascripts codes from https://github.com/ipfs/js-ipfs-api/tree/master/examples/upload-file-via-browser.

However this method need to expose IPFS API (port 5001) to the network. Exposing IPFS API to outside network is not secure in the real world. My questions is beside uploading file(s) through IPFS API (port 5001), Is there any more secure way to upload file or directory into IPFS (for example through IPFS Gateway, port 8080)? If there is better way to do it, would you please give me some details about how to implement it? Thank you for your comments.

2 Likes

I’m currently working on a project called Temporal which exposes an easy to use API for interacting with IPFS nodes and more without exposing access to the underlying IPFS API that runs on port 5001. https://github.com/RTradeLtd/Temporal

You either have to expose direct access to port 5001 and lock it down, or create some sort of API to intercept requests and forward them to the IPFS node.

@postables: My concerns is if we allow people to upload files through API port 5001, the uploaded files will remain in the IPFS blocks system forever and we can’t control these files since we don’t know the files’ hash id. Is there any way we can upload files into IPFS and just allowing them staying in the IPFS temporarily and after certain period of time, these files will be deleted through garbage collect process? Any comments will be highly appreciated. Thanks.

Kevin

That’s not quite how IPFS works I would recommend reading in more detail about how the system works. You can add files through the API and still have them get GCd.

Check out IpfsCloud: http://ipfscloud.store

An online cloud storage service using IPFS which allows a really easy interface that a normal internet user can use.

Read more about it here: https://medium.com/ipfscloud/

1

I’ve tried solution by @vasa-develop but it’s not reliable: https://github.com/cluster-labs/ipfscloud-web/issues/20

#2
I’ve fixed some issues with: https://medium.com/@angellopozo/uploading-an-image-to-ipfs-e1f65f039da4

  • curly quotes in code snippets
  • browserified buffer dependency

#3
Stack Overflow question: “How to add a file to IPFS using the API?”


Surely I miss something, it cannot be that difficult.

How to simply upload to IPFS without having my own server?

(serverless architecture)

You can use Infura servers and use ipfs-http-client to connect and upload data to the infura ipfs servers.

Note: The Infura IPFS servers don’t allow to upload big files. I am not sure about the upper limit of the file size, but I have tried it, and it throws error above a certain limit.

Last night I’ve tried using ipfs-http-client Infura: https://github.com/INFURA/infura/issues/181

(the issue contains a super simple code case)

Here is the video illustrating the issue: https://youtu.be/nTDoBBvGCsQ (loads of links in description)

Despite a few days of effort still didn’t figure it out.

You need to specify the “https” protocol. Try initializing IPFS like this:

var ipfs = ipfsClient('ipfs.infura.io', '5001', { protocol: 'https' })

Getting closer, see the video: https://youtu.be/_pKHlUAA1kY

Codepen: https://codepen.io/marsrobertson/pen/NmordZ?editors=1010

Accessing file gateway seems to take forever.

As I uploaded video, added description, formatted codepen, checked Infura status page, the gateway finally resolved.

Is couple minutes delay expected?

The delay is normal.

BTW, I added a new dedicated server for ipfscloud.
Now you can try this out: https://github.com/cluster-labs/ipfscloud-web#ipfscloud-upload-button-widget