Skip to content

Commit a8ceb78

Browse files
stephenplusplusjkwlui
authored andcommitted
feat(file): allow setting configPath of resumable upload (#642)
* feat(file): allow setting configPath of resumable upload * gts fix
1 parent 1146b5e commit a8ceb78

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/file.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export type PredefinedAcl =
179179
| 'publicRead';
180180

181181
export interface CreateResumableUploadOptions {
182+
configPath?: string;
182183
metadata?: Metadata;
183184
origin?: string;
184185
offset?: number;
@@ -1426,6 +1427,10 @@ class File extends ServiceObject<File> {
14261427
*/
14271428
/**
14281429
* @typedef {object} CreateResumableUploadOptions
1430+
* @property {string} [configPath] Where the `gcs-resumable-upload`
1431+
* configuration file should be stored on your system. This maps to the
1432+
* [configstore option by the same
1433+
* name](https://github.com/yeoman/configstore/tree/0df1ec950d952b1f0dfb39ce22af8e505dffc71a#configpath).
14291434
* @property {object} [metadata] Metadata to set on the file.
14301435
* @property {string} [origin] Origin header to set for the upload.
14311436
* @property {string} [predefinedAcl] Apply a predefined set of access
@@ -1509,6 +1514,7 @@ class File extends ServiceObject<File> {
15091514
{
15101515
authClient: this.storage.authClient,
15111516
bucket: this.bucket.name,
1517+
configPath: options.configPath,
15121518
file: this.name,
15131519
generation: this.generation,
15141520
key: this.encryptionKey,
@@ -1527,6 +1533,10 @@ class File extends ServiceObject<File> {
15271533

15281534
/**
15291535
* @typedef {object} CreateWriteStreamOptions Configuration options for File#createWriteStream().
1536+
* @property {string} [configPath] **This only applies to resumable
1537+
* uploads.** Where the `gcs-resumable-upload` configuration file should
1538+
* be stored on your system. This maps to the [configstore option by the same
1539+
* name](https://github.com/yeoman/configstore/tree/0df1ec950d952b1f0dfb39ce22af8e505dffc71a#configpath).
15301540
* @property {string} [contentType] Alias for
15311541
* `options.metadata.contentType`. If set to `auto`, the file name is used
15321542
* to determine the contentType.
@@ -3257,6 +3267,7 @@ class File extends ServiceObject<File> {
32573267
const uploadStream = resumableUpload.upload({
32583268
authClient: this.storage.authClient,
32593269
bucket: this.bucket.name,
3270+
configPath: options.configPath,
32603271
file: this.name,
32613272
generation: this.generation,
32623273
key: this.encryptionKey,

test/file.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,7 @@ describe('File', () => {
15111511

15121512
it('should create a resumable upload URI', done => {
15131513
const options = {
1514+
configPath: '/Users/user/.config/here',
15141515
metadata: {
15151516
contentType: 'application/json',
15161517
},
@@ -1533,6 +1534,7 @@ describe('File', () => {
15331534

15341535
assert.strictEqual(opts.authClient, storage.authClient);
15351536
assert.strictEqual(opts.bucket, bucket.name);
1537+
assert.strictEqual(opts.configPath, options.configPath);
15361538
assert.strictEqual(opts.file, file.name);
15371539
assert.strictEqual(opts.generation, file.generation);
15381540
assert.strictEqual(opts.key, file.encryptionKey);
@@ -3671,6 +3673,7 @@ describe('File', () => {
36713673
describe('starting', () => {
36723674
it('should start a resumable upload', done => {
36733675
const options = {
3676+
configPath: '/Users/user/.config/here',
36743677
metadata: {},
36753678
offset: 1234,
36763679
public: true,
@@ -3693,6 +3696,7 @@ describe('File', () => {
36933696

36943697
assert.strictEqual(opts.authClient, authClient);
36953698
assert.strictEqual(opts.bucket, bucket.name);
3699+
assert.strictEqual(opts.configPath, options.configPath);
36963700
assert.strictEqual(opts.file, file.name);
36973701
assert.strictEqual(opts.generation, file.generation);
36983702
assert.strictEqual(opts.key, file.encryptionKey);

0 commit comments

Comments
 (0)