Skip to content

Commit

Permalink
Uses Buffer for Dropbox batch uploads
Browse files Browse the repository at this point in the history
Closes #130
  • Loading branch information
JbIPS committed Nov 26, 2017
1 parent 36fe9a2 commit 3a9c8e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]
### Fixed
- [Dropbox] Batch correctly overwrite existing files
- [Dropbox] Batch now correctly rejects the promise if one action failed
- [Dropbox] Batch correctly overwrite existing files (https://github.com/silexlabs/unifile/issues/131)
- [Dropbox] Batch now correctly rejects the promise if one action failed (https://github.com/silexlabs/unifile/issues/131)
- [Dropbox] Batch upload uses `Buffer` for file content and supports UTF-8 (https://github.com/silexlabs/unifile/issues/130)

## [2.0.0] - 2017-11-25
### Changed
Expand All @@ -15,7 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Remove parameters mutations
- `.readFile()` now always return a `Buffer`
- [Dropbox] Retrieve account when providing only the token
- [Dropbox] Normalize errors (as for #103)
- [Dropbox] Normalize errors (https://github.com/silexlabs/unifile/issues/103)

### Added
- Tools, index and FS are 100% covered
Expand All @@ -24,7 +25,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed
- In SFTP, directory type is now set to 'application/directory'
- [Dropbox] Fixes batch upload (Closes ##114)
- [Dropbox] Fixes batch upload (https://github.com/silexlabs/unifile/issues/114)

### Removed
- WebDAV connector is now a separate plugin
Expand Down
5 changes: 3 additions & 2 deletions lib/unifile-dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,13 @@ class DropboxConnector {
const toUpload = uploadEntries.slice();
actionsChain = actionsChain.then(() => {
return Promise.map(toUpload, (action) => {
return openUploadSession(session, action.content, true)
const bitContent = new Buffer(action.content);
return openUploadSession(session, bitContent, true)
.then((result) => {
return {
cursor: {
session_id: result.session_id,
offset: action.content.length
offset: bitContent.length
},
commit: {
path: makePathAbsolute(action.path),
Expand Down
17 changes: 17 additions & 0 deletions test/unifile-dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,23 @@ describe('DropboxConnector', function() {
});
});

it('can write files with special chars', function() {
const path = 'tmp/specialFile';
const fileContent = 'Àà çéèîï';
return connector.batch(session, [{
name: 'writefile',
path: path,
content: fileContent
}])
.then(() => {
return connector.readFile(session, path);
})
.then((content) => {
return expect(content.toString()).to.equal(fileContent);
})
.then(() => connector.rmdir(session, 'tmp'));
});

it('can overwrite existing files', function() {
const path = 'tmp/indexFile';
const fileContent = 'html';
Expand Down

0 comments on commit 3a9c8e3

Please sign in to comment.