@google-cloud/storage - createResumableUpload and custom file metadata (#19006)

* @google-cloud/storage - createResumableUpload and custom file metadata

Add typings for File.createResumableUpload and the ability to define custom metadata on files.

* Moved createResumeableUpload to File.  Added test for createResumableUpload.
This commit is contained in:
seyfert
2017-08-16 15:37:26 -07:00
committed by Mohamed Hegazy
parent 328aec4c8b
commit f455e81db0
2 changed files with 31 additions and 0 deletions
@@ -19,6 +19,7 @@ import {
FileMetadata,
FilePrivateOptions,
ReadStreamOptions,
ResumableUploadOptions,
SignedPolicy,
SignedPolicyOptions,
SignedUrlConfig,
@@ -247,6 +248,16 @@ export class TestFile {
return this.file.copy(destination);
}
/**
* Create a unique resumable upload session URI. This is the first step when performing a resumable upload.
* @method createResumableUpload
* @param {ResumableUploadOptions} options
* @return {Promise<[string]}
*/
createResumableUpload(options?: ResumableUploadOptions): Promise<[string]> {
return this.file.createResumableUpload(options);
}
/**
* Create a readable stream to read the contents of the remote file.
* It can be piped to a writable stream or listened to for 'data' events to read a file's contents.
+20
View File
@@ -121,6 +121,7 @@ declare namespace Storage {
acl: Acl;
copy(destination: string | Bucket | File): Promise<[File, ApiResponse]>;
createReadStream(options?: ReadStreamOptions): ReadStream;
createResumableUpload(options?: ResumableUploadOptions): Promise<[string]>;
createWriteStream(options?: WriteStreamOptions): WriteStream;
delete(): Promise<[ApiResponse]>;
download(options?: DownloadOptions): Promise<[Buffer]>;
@@ -139,11 +140,19 @@ declare namespace Storage {
metadata?: FileMetadata;
}
/**
* User-defined metadata.
*/
interface CustomFileMetadata {
[key: string]: boolean | number | string | null;
}
/**
* File metadata.
*/
interface FileMetadata {
contentType?: string;
metadata?: CustomFileMetadata;
}
/**
@@ -192,6 +201,17 @@ declare namespace Storage {
responseType?: string;
}
/**
* Options when obtaining a resumable upload URI.
*/
interface ResumableUploadOptions {
metadata?: FileMetadata;
origin?: string;
predefinedAcl?: string;
private?: boolean;
public?: boolean;
}
/**
* Access control list for storage buckets and files.
*/