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

Support adding files using filestore #843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

skeary-immt
Copy link

Hi,
Here is a small change to support adding files using the filestore in go-ipfs via the HTTP API.
As described in #562, In order to use the filestore, an Abspath header must be specified which indicates the full path of the file in the local file system. This change provides a way to specify this header by using client code of the form:

  const filesAdded = await ipfs.files.add(
    {
      path: 'filename',
      abspath: '/full/path/to/filename',
      content: fs.createReadStream('/full/path/to/filename')
    },
    {
      nocopy: true,
    }
  )

Based on my testing, when using the updated code, and specifying the abspath and nocopy options, the go-ipfs daemon then uses the filestore for the added file.

I'm not sure if the best approach but wanted to create the pull request for consideration. I'm happy to update to an alternative approach if there is a better way. I think an update would also need to be done to the IPFS API spec but I can later do that if it's thought this approach has merit.

Thanks,
Simon

@skeary-immt
Copy link
Author

Oh, I just realised there is another PR #564 that appears to try and solve this issue too....

I'll leave this open as the approaches are a bit different so it may be worth reviewing my changes to see how it compares and whether it is the basis of something better or not. (I'm new to IPFS so could quite easily be missing something in what I've done...)

@alanshaw
Copy link
Contributor

@skeary-immt this LGTM on the surface - is there any chance we can get a test?

@parkan
Copy link

parkan commented Feb 15, 2019

would it make sense to make sending the header conditional on nocopy, as well?

@obo20
Copy link
Contributor

obo20 commented Mar 1, 2019

@alanshaw What's all needed for the --nocopy functionality to get fully implemented? I'd really love to see this functionality as part of this library, but I imagine there's a few more things that need to happen for this to become a reality.

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

Successfully merging this pull request may close these issues.

6 participants