Socket
Socket
Sign inDemoInstall

backblaze-b2

Package Overview
Dependencies
7
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

9

CHANGELOG.md

@@ -0,1 +1,10 @@

### v1.0.4 (November 30, 2017) - The buffed release
Features
- Hash argument for uploadFile() [link](https://github.com/yakovkhalinsky/backblaze-b2/pull/39)
Thanks to the contributors for this release
- [Jamie Syme](https://github.com/jamiesyme)
### v1.0.3 (November 30, 2017) - The authorization release

@@ -2,0 +11,0 @@

3

lib/actions/file.js

@@ -13,2 +13,3 @@ var sha1 = require('sha1');

var data = args.data;
var hash = args.hash;
var info = args.info;

@@ -24,3 +25,3 @@ var mime = args.mime;

'X-Bz-File-Name': filename,
'X-Bz-Content-Sha1': data ? sha1(data) : null
'X-Bz-Content-Sha1': hash || (data ? sha1(data) : null)
},

@@ -27,0 +28,0 @@ data: data,

@@ -42,2 +42,3 @@ var actions = require('./actions');

// - data
// - hash (optional)
B2.prototype.uploadFile = function(args) {

@@ -44,0 +45,0 @@ return actions.file.uploadFile(this, args);

{
"name": "backblaze-b2",
"version": "1.0.3",
"version": "1.0.4",
"description": "Node.js Library for the Backblaze B2 Storage Service",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -154,4 +154,5 @@ ### Backblaze B2 Node.js Library

filename: 'filename',
mime: '', // optonal mime type, will default to 'b2/x-auto' if not provided
data: 'data', // this is expecting a Buffer not an encoded string,
mime: '', // optional mime type, will default to 'b2/x-auto' if not provided
data: 'data', // this is expecting a Buffer, not an encoded string
hash: 'sha1-hash', // optional data hash, will use sha1(data) if not provided
info: {

@@ -158,0 +159,0 @@ // optional info headers, prepended with X-Bz-Info- when sent, throws error if more than 10 keys set

@@ -181,2 +181,45 @@ var expect = require('expect.js');

describe('with no hash specified', function() {
beforeEach(function(done) {
options = {
uploadUrl: 'https://uploadUrl',
uploadAuthToken: 'uploadauthtoken',
filename: 'foo.txt',
data: 'some text file content'
};
file.uploadFile(b2, options).then(function() {
done();
});
});
it('should hash the data for x-bz-content-sha1 in headers', function() {
expect(requestOptions.headers['X-Bz-Content-Sha1']).to.equal('332e7f863695677895a406aff6d60acf7e84ea22');
});
});
describe('with hash specified', function() {
beforeEach(function(done) {
options = {
uploadUrl: 'https://uploadUrl',
uploadAuthToken: 'uploadauthtoken',
filename: 'foo.txt',
data: 'some text file content',
hash: 'my hash value'
};
file.uploadFile(b2, options).then(function() {
done();
});
});
it('should properly set x-bz-content-sha1 in headers', function() {
expect(requestOptions.headers['X-Bz-Content-Sha1']).to.equal('my hash value');
});
});
});

@@ -183,0 +226,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc