Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

ipfs-http-client upload folder not work #3873

Closed
ziboilihua opened this issue Sep 15, 2021 · 2 comments
Closed

ipfs-http-client upload folder not work #3873

ziboilihua opened this issue Sep 15, 2021 · 2 comments
Labels
need/triage Needs initial labeling and prioritization

Comments

@ziboilihua
Copy link

  • Version:
    {
    version: '0.9.1',
    commit: 'dc2715a',
    repo: '11',
    system: 'amd64/linux',
    golang: 'go1.15.2'
    }

  • Platform:
    Darwin localhost 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64

Severity:

High

Description:

ipfs-http-client will throw this error when add Folder use globSource, I use it in nodejs project at local

AbortError: The user aborted a request.

Steps to reproduce the error:

const { create, globSource } = require('ipfs-http-client')

async function uploadFile() {
    const ipfs = create('http://localhost:15001');
    const file = await ipfs.add(globSource('./docs', { recursive: true }))
    console.log(JSON.stringify(file))
}

uploadFile();
@ziboilihua ziboilihua added the need/triage Needs initial labeling and prioritization label Sep 15, 2021
@welcome
Copy link

welcome bot commented Sep 15, 2021

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@achingbrain
Copy link
Member

ipfs.add only accepts single items to add to IPFS. globSource returns multiple items which is why you're seeing an error, though granted the error message could be more descriptive.

Please change the invocation to:

const file = await ipfs.addAll(globSource('./docs', { recursive: true }))

Also note the globSource API changed in the ipfs-http-client@53.x.x release so now it would be:

const file = await ipfs.addAll(globSource('.', 'docs/**/*'))

// or if you prefer:

const file = await ipfs.addAll(globSource('./docs', '**/*'), {
  wrapWithDirectory: true
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

2 participants