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

Conversation

@travisperson
Copy link
Contributor

This PR adds stream support for any command send data through the files argument of send. It addresses issue #4 and #3.

Appropriate values for any files argument are streams, vinyl files, or buffers. Any stream or buffer will be converted to a vinyl file with the cwd, base, and path set to /, which basically is just an unnamed file.

The base of any filename is the relative pathing from the vinyl file base.

Wrapped files in a directory

files.push(new File({
    base: '/',
    path: '/base/dir/hello.txt',
    contents: new Buffer("world")
}))

files.push(new File({
    base: '/',
    path: '/base/dir/ipfs.txt',
    contents: new Buffer("is cool")
}))

files.push(new File({
    base: '/',
    path: '/base/readme.md',
    contents: new Buffer("wow")
}))

files.push(new File({
    base: '/',
    path: '/base/dir/other/readme.md',
    contents: new Buffer("wow")
}))
{
  "Name": "base/readme.md",
  "Hash": "QmbxMp5x7RbqHSTrrKQCYjccw2obvgcz2GEyz3gEkixhDS"
}
{
  "Name": "base/dir/hello.txt",
  "Hash": "QmNyJpQkU1cEkBwMDhDNFstr42q55mqG5GE5Mgwug4xyGk"
}
{
  "Name": "base/dir/ipfs.txt",
  "Hash": "QmfBfWxn32sGXbkgDoeNLT5rBcTehYffMyeU5LFTTByt6V"
}
{
  "Name": "base/dir/other/readme.md",
  "Hash": "QmbxMp5x7RbqHSTrrKQCYjccw2obvgcz2GEyz3gEkixhDS"
}
{
  "Name": "base/dir/other",
  "Hash": "QmSV3qfAxjMTdGrB5tGA4daPsL6NoZKxhUx6QxCfqLCeGp"
}
{
  "Name": "base/dir",
  "Hash": "QmeE8ZjMwexLbZBAX1dxwguCaQ5xyHw4wYGmGiyfzEqL2p"
}
{
  "Name": "base",
  "Hash": "QmeUg1UYEAmrZZWW7URFZXMYMVECzfmgdgke95F8HqauLz"
}

Grouping of files

files.push(new File({
    base: '/base/',
    path: '/base/dir/hello.txt',
    contents: new Buffer("world")
}))

files.push(new File({
    base: '/base/',
    path: '/base/dir/ipfs.txt',
    contents: new Buffer("is cool")
}))

files.push(new File({
    base: '/base/',
    path: '/base/readme.md',
    contents: new Buffer("wow")
}))

files.push(new File({
    base: '/base/',
    path: '/base/dir/other/readme.md',
    contents: new Buffer("wow")
}))
{
  "Name": "readme.md",
  "Hash": "QmbxMp5x7RbqHSTrrKQCYjccw2obvgcz2GEyz3gEkixhDS"
}
{
  "Name": "dir/hello.txt",
  "Hash": "QmNyJpQkU1cEkBwMDhDNFstr42q55mqG5GE5Mgwug4xyGk"
}
{
  "Name": "dir/ipfs.txt",
  "Hash": "QmfBfWxn32sGXbkgDoeNLT5rBcTehYffMyeU5LFTTByt6V"
}
{
  "Name": "dir/other/readme.md",
  "Hash": "QmbxMp5x7RbqHSTrrKQCYjccw2obvgcz2GEyz3gEkixhDS"
}
{
  "Name": "dir/other",
  "Hash": "QmSV3qfAxjMTdGrB5tGA4daPsL6NoZKxhUx6QxCfqLCeGp"
}
{
  "Name": "dir",
  "Hash": "QmeE8ZjMwexLbZBAX1dxwguCaQ5xyHw4wYGmGiyfzEqL2p"
}

*Note: this is slight different from what was shown in #3.

Start of moving to supporting streams, also now support folder
uploading.
Start of moving to supporting streams, also now support folder
uploading.
@jbenet
Copy link
Contributor

jbenet commented Jun 4, 2015

LGTM -- @krl @mappum ?

@krl
Copy link
Contributor

krl commented Jun 4, 2015

cool, looking good

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants