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

feature/files add #67

Merged
merged 1 commit into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ node_js:
- "4"
- "5"

branches:
only:
- master

before_install:
- npm i -g npm
# Workaround for a permissions issue with Travis virtual machine images

addons:
firefox: 'latest'

script:
- npm test

Expand Down
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = function (config) {
},
externals: {
fs: '{}',
'node-forge': 'forge'
'node-forge': 'forge',
'ipfs-data-importing': '{ import: {} }'
},
node: {
Buffer: true
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"hapi": "^12.0.0",
"ipfs-api": "^2.13.1",
"ipfs-blocks": "^0.1.0",
"ipfs-data-importing": "^0.3.0",
"ipfs-merkle-dag": "^0.2.1",
"ipfs-multipart": "^0.1.0",
"ipfs-repo": "^0.5.0",
Expand Down
10 changes: 0 additions & 10 deletions src/cli/commands/add.js

This file was deleted.

33 changes: 33 additions & 0 deletions src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict'

const Command = require('ronin').Command
const IPFS = require('../../../ipfs-core')
const debug = require('debug')
const log = debug('cli:version')
log.error = debug('cli:version:error')
const bs58 = require('bs58')

module.exports = Command.extend({
desc: 'Add a file to IPFS using the UnixFS data format',

options: {
recursive: {
alias: 'r',
type: 'boolean',
default: false
}
},

run: (recursive, path) => {
var node = new IPFS()
path = process.cwd() + '/' + path
node.files.add(path, {
recursive: recursive
}, (err, stats) => {
if (err) {
return console.log(err)
}
console.log('added', bs58.encode(stats.Hash).toString(), stats.Name)
})
}
})
2 changes: 1 addition & 1 deletion src/http-api/resources/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ exports.replace = {
}

const parser = multipart.reqParser(request.payload)
let file
var file

parser.on('file', (fileName, fileStream) => {
fileStream.on('data', (data) => {
Expand Down
2 changes: 1 addition & 1 deletion src/http-api/resources/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ exports.put = {
}

const parser = multipart.reqParser(request.payload)
let file
var file

parser.on('file', (fileName, fileStream) => {
fileStream.on('data', (data) => {
Expand Down
9 changes: 9 additions & 0 deletions src/ipfs-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const DAGService = mDAG.DAGService
const Id = require('peer-id')
const Info = require('peer-info')
const multiaddr = require('multiaddr')
const importer = require('ipfs-data-importing').import

exports = module.exports = IPFS

Expand Down Expand Up @@ -320,6 +321,14 @@ function IPFS (repo) {
records: {},
ping: notImpl
}

this.files = {
add: (path, options, callback) => {
options.path = path
options.dagService = dagS
importer(options, callback)
}
}
}

function notImpl () {
Expand Down