-
Notifications
You must be signed in to change notification settings - Fork 299
flattened multipart message and new ipfsAPI().add
API
#178
Comments
|
Changed .add([
{path: 'my/file.txt', content: <stream or buffer or string>}
{path: 'my/folder', dir: true}
]) |
While investigating how symlinks are handled on
(You can see the wireshark captures here: https://gist.github.com/xicombd/174f3af4ad7e341f2f56) Should we keep the follow symlinks functionality on by default on I'll try to fix the |
what's about a stream of file objects (file objects as specified by @dignifiedquire)? this would enable file streaming. atm all files are loaded into the memory and then passed to the ipfs api. but with streams (and back pressure magicz) only a limited amount of files are needed to be in ram. |
import ipfsApi from 'ipfs-api';
import streamMap from 'through2-map';
const ipfs = ipfsApi({...});
const addStream = ipfs.createAddStream(); // with an implicit {recursive: true}
// then use it with eg gulp/vinyl file objects:
gulp.src('bla/**/*')
.pipe(...)
.pipe(streamMap.obj(v => ({path: v.relative, content: v.contents}))) // convert vinyl to "file object"
.pipe(addStream); i dont think we could put this functionality into the current ipfs.add function and pass the stream to it, cause we couldnt exactly determine the stream type. also it would be more "node like" (fs.createWriteStream). Passing an array of file streams, aka: ipfs.add([{
{path: 'foo', content: fs.createReadStream('foo')},
{path: 'foo2', content: fs.createReadStream('foo2')},
}]); has a few disadvantages:
|
What exactly do we want to do here, the refactoring which was mentioned at the beginning of the issue was done and released. |
I think we are good in this one :) |
The latest 0.4.0 version has an update on what it is expecting when it comes to multipart messages which breaks how
ipfs add -r
. multipart messages have been historically a pain to handle, parse and construct. A new and cleaner way to do it is simply to flat the multipart messages (avoiding the nesting).In order to let the IPFS HTTP API to know if we are sending a file, directory or symlink, ipfsAPI client will send the following "Content-Type":
application/x-directory
when it is a directoryapplication/x-symlink
when it is a symlinkapplication/octet-stream
when it is a fileThe
.add
interface is going to be updated to:This calls will create always a flatened multipart message
@whyrusleeping @dignifiedquire
The text was updated successfully, but these errors were encountered: