8000 [storage] [openstack] bulk-operation archive by lynchmaniac · Pull Request #595 · pkgcloud/pkgcloud · GitHub
[go: up one dir, main page]

Skip to content
Open
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
26 changes: 26 additions & 0 deletions docs/providers/openstack/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ client.removeContainerMetadata(container, { year: false }, function(err, c) {
* [`client.getFiles(container, function(err, file) { })`](#clientgetfilescontainer-functionerr-file--)
* [`client.removeFile(container, file, function(err, result) { })`](#clientremovefilecontainer-file-functionerr-result--)
* [`client.updateFileMetadata(container, file, function(err, file) { })`](#clientupdatefilemetadatacontainer-file-functionerr-file--)
* [`client.bulkDelete(container, files, function(err, file) { })`](#clientbulkdeletecontainer-files-functionerr-file--)
* [`client.bulkArchive(container, file, function(err, file) { })`](#clientbulkarchivecontainer-file-functionerr-file--)


### File API Details

Expand Down Expand Up @@ -266,3 +269,26 @@ client.updateFileMetadata(file.container, file, function(err, file) {
});
```

#### client.bulkDelete(container, files, function(err, file) { })

Remove a list of files from a container

```javascript

client.bulkDelete(containerName, files, function(err, results) {
// ...
});
```

#### client.bulkArchive(container, file, function(err, file) { })

Upload and extract an archive file

```javascript

var readStream = fs.createReadStream(archivePath);
client.bulkArchive(containerName, readStream, function(err, results) {
// ...
});
```

27 changes: 27 additions & 0 deletions lib/pkgcloud/openstack/storage/client/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ exports.bulkDelete = function(container, files, callback) {
});
};

/**
* client.bulkArchive
*
* @description upload and extract an archive file
*
* @param {String|object} container the container or containerName
* @param {String} file the archive file to expand
* @param callback
*/
exports.bulkArchive = function(container, file, callback) {
this._request({
method: 'PUT',
container: container,
body: file,
headers: {
'Content-Type': 'application/x-tar'
},
qs: {
'extract-archive': 'tar.gz'
}
}, function(err, results) {
return err
? callback(err)
: callback(null, results);
});
};

/**
* client.upload
*
Expand Down
0