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

Issue with example for ipfs add #3740

Closed
sreeharshar84 opened this issue Jul 8, 2021 · 4 comments · Fixed by #3866
Closed

Issue with example for ipfs add #3740

sreeharshar84 opened this issue Jul 8, 2021 · 4 comments · Fixed by #3866
Labels
good first issue Good issue for new contributors help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) topic/docs Documentation

Comments

@sreeharshar84
Copy link

The example in ipfs.add (https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md#ipfsadddata-options) lists the following example.

This is clearly wrong, there is no variable with the name "content"

const file = {
path: '/tmp/myfile.txt',
content: 'ABC'
}

const result = await ipfs.add(content)

console.info(result)

/*
Prints:
{
"path": "tmp",
"cid": CID("QmWXdjNC362aPDtwHPUE9o2VMqPeNeCQuTBTv1NsKtwypg"),
"mode": 493,
"mtime": { secs: Number, nsecs: Number },
"size": 67
}
*/

  • Version:
  • Platform:
  • Subsystem:

Severity:

Description:

Steps to reproduce the error:

@sreeharshar84 sreeharshar84 added the need/triage Needs initial labeling and prioritization label Jul 8, 2021
@welcome
Copy link

welcome bot commented Jul 8, 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.

@TheDiscordian
Copy link
Member

TheDiscordian commented Jul 9, 2021

Appears to be a typo in your example:

const result = await ipfs.add(content)

should be:

const result = await ipfs.add(file)

Edit: Oh I see, that's straight from the docs. Good eye.

@sreeharshar84
Copy link
Author

This worked for me:
var currentDate = new Date().getTime();
const input = [{
.....
{
"trait_type": "date",
"value": currentDate
}
]
}]
const file = {
path: '/tmp/myfile.txt',
content: Buffer.from(JSON.stringify(input))
}

  const result = await ipfs.add(file)
  
  console.info(result)

@BigLep
Copy link
Contributor

BigLep commented Aug 27, 2021

@sreeharshar84 or @TheDiscordian : thanks for catching. Can you make a PR for the doc update please?

@BigLep BigLep added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Aug 27, 2021
@lidel lidel added kind/bug A bug in existing code (including security flaws) topic/docs Documentation good first issue Good issue for new contributors help wanted Seeking public contribution on this issue and removed need/author-input Needs input from the original author labels Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good issue for new contributors help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) topic/docs Documentation
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants