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

Commit

Permalink
feat: allow additional configurability to set method
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu committed Apr 17, 2018
1 parent 5c897e2 commit c035fce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ module.exports = class SinkGCS extends EventEmitter {
}
}

async set(fileName, fileContent, metadata = {}) {
async set(fileName, fileContent, options = {}) {
assert(fileName, 'Expected "fileName" to be provided, none given.');
assert(
fileContent,
Expand All @@ -218,12 +218,15 @@ module.exports = class SinkGCS extends EventEmitter {
`Instead extension "${ext}" resolved to content type "${contentType}"`
);

const metadata = { contentType, ...(options.metadata || {}) };

await this[ready];
const file = this[getGcsFile](fileName);
const saveFile = () =>
file.save(fileContent, {
metadata: { contentType, ...metadata },
metadata,
resumable: false,
public: options.public !== false,
});
try {
return await pRetry(saveFile, { retries: 3 });
Expand Down

0 comments on commit c035fce

Please sign in to comment.