-
Notifications
You must be signed in to change notification settings - Fork 299
ipfs add url wrap doesn't work #140
Comments
The main thing to do here is extracting the filename from a given url and passing it as a parameter. |
@dignifiedquire something like this? var s = url.split('#')[0].split('/')
filename = s[name.length - 1].trim()
if(filename.length === 0) filename = 'index.html' |
@fazo96 yes, and then pass it like this |
Or you could look into using https://nodejs.org/docs/latest/api/url.html |
yourFilename = require('path').basename(
require('url').parse(yourURL).pathname
) |
We have https://github.com/ipfs/js-ipfs-api#add-a-file-from-a-url-to-ipfs and tests https://github.com/ipfs/js-ipfs-api/blob/master/test/ipfs-api/util.spec.js#L73-L86, I'll call this done unless someone is still hitting a issue, let me know and we will reopen and check again. Bonus if you provide a test case :D |
Wait, does the API has anything equivalent to |
@diasdavid is this issue still valid? As far as I know, the const ipfsAPI = require('.')
const ipfs = ipfsAPI('/ip4/127.0.0.1/tcp/5001')
ipfs.util.addFromURL('https://hacdias.com/downloads/aprenda_a_programar.pdf', {wrapWithDirectory: true}, (err, result) => {
console.log(result)
}) Prints:
Edit: noticed that it lacks the filename on |
Expected:
would be equivalent to cli's
ipfs add -w
, preserving the last pathname.The text was updated successfully, but these errors were encountered: