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

Support "+" character in file paths #587

Closed
@petethomas

Description

@petethomas

Adding a file that includes + characters in path can result in a stored path that uses spaces instead. For example:

const ipfsAPI = require('ipfs-api')
const ipfs = ipfsAPI()
ipfs.files.add(
  [{
    path: 'ti,c64x+megamod-pic.txt',
    content: Buffer.from('testing', 'utf-8')
  }],
  (err, res) => {
    if (err) done(err)
    console.log(res)
  }
)

Current result:

[ { path: 'ti,c64x megamod-pic.txt',
    hash: 'QmZJsQUWUes6vz6DzDT3z6383k1Y4hFYUKun9UkPN1PYSX',
    size: 15 } ]

Expected result:

[ { path: 'ti,c64x+megamod-pic.txt',
    hash: 'QmZJsQUWUes6vz6DzDT3z6383k1Y4hFYUKun9UkPN1PYSX',
    size: 15 } ]

Expected result preserves +s similar to the command-line utility. For example:

λ ipfs add -w ~/projects/linux/Documentation/devicetree/bindings/interrupt-controller/ti,c64x+megamod-pic.txt
added QmQ2eHGDMqC7dBD44EJFQRqkypPKQ9z9coBi1VX7vBZhPZ ti,c64x+megamod-pic.txt
added QmXdMfwwg4xrVVHo8YGwjbRChnM22UCs21r4zWFgmjeZKU
λ ipfs get QmXdMfwwg4xrVVHo8YGwjbRChnM22UCs21r4zWFgmjeZKU
Saving file(s) to QmXdMfwwg4xrVVHo8YGwjbRChnM22UCs21r4zWFgmjeZKU
 4.03 KB / 4.03 KB [============================================================================================================================================================================] 100.00% 0s
λ cd QmXdMfwwg4xrVVHo8YGwjbRChnM22UCs21r4zWFgmjeZKU/
λ ls
ti,c64x+megamod-pic.txt
λ

I think this package can achieve parity by URI-encoding the path before getting the file stream.

-pete

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions