gcs-resumable-upload
- Version 6.0.0
- Published
- 102 kB
- 8 dependencies
- MIT license
Install
npm i gcs-resumable-upload
yarn add gcs-resumable-upload
pnpm add gcs-resumable-upload
Overview
Upload a file to Google Cloud Storage with built-in resumable behavior
Index
Variables
Functions
Classes
Upload
- apiEndpoint
- authClient
- authConfig
- baseURI
- bucket
- cacheKey
- chunkSize
- configStore
- contentLength
- createURI()
- createURIAsync()
- customRequestOptions
- deleteConfig()
- encryption
- file
- generation
- isServerErrorResponse()
- isSuccessfulResponse()
- key
- kmsKeyName
- maxRetryDelay
- maxRetryTotalTimeout
- metadata
- numBytesWritten
- numRetries
- offset
- origin
- params
- predefinedAcl
- private
- public
- retryableErrorFn
- retryDelayMultiplier
- retryLimit
- startUploading()
- timeOfFirstRequest
- uri
- uriProvidedManually
- userProject
Interfaces
Type Aliases
Variables
variable PROTOCOL_REGEX
const PROTOCOL_REGEX: RegExp;
Functions
Classes
class Upload
class Upload extends Pumpify {}
constructor
constructor(cfg: UploadConfig);
property apiEndpoint
apiEndpoint: string;
property authClient
authClient: { request: <T>(opts: GaxiosOptions) => any };
property authConfig
authConfig?: { scopes?: string[] };
property baseURI
baseURI: string;
property bucket
bucket: string;
property cacheKey
cacheKey: string;
property chunkSize
chunkSize?: number;
property configStore
configStore: ConfigStore;
property contentLength
contentLength: number | '*';
property customRequestOptions
customRequestOptions: GaxiosOptions;
property encryption
encryption?: Encryption;
property file
file: string;
property generation
generation?: number;
property key
key?: any;
property kmsKeyName
kmsKeyName?: string;
property maxRetryDelay
maxRetryDelay: number;
property maxRetryTotalTimeout
maxRetryTotalTimeout: number;
property metadata
metadata: ConfigMetadata;
property numBytesWritten
numBytesWritten: number;
property numRetries
numRetries: number;
property offset
offset?: number;
property origin
origin?: string;
property params
params: QueryParameters;
property predefinedAcl
predefinedAcl?: PredefinedAcl;
property private
private?: boolean;
property public
public?: boolean;
property retryableErrorFn
retryableErrorFn?: (err: ApiError) => boolean;
property retryDelayMultiplier
retryDelayMultiplier: number;
property retryLimit
retryLimit: number;
property timeOfFirstRequest
timeOfFirstRequest: number;
property uri
uri?: string;
property uriProvidedManually
uriProvidedManually: boolean;
property userProject
userProject?: string;
method createURI
createURI: { (): Promise<string>; (callback: CreateUriCallback): void };
method createURIAsync
protected createURIAsync: () => Promise<string>;
method deleteConfig
deleteConfig: () => void;
method isServerErrorResponse
isServerErrorResponse: (status: number) => boolean;
Check if a given status code is 5xx
Parameter status
The status code to check
Returns
if the status is 5xx
method isSuccessfulResponse
isSuccessfulResponse: (status: number) => boolean;
Check if a given status code is 2xx
Parameter status
The status code to check
Returns
if the status is 2xx
method startUploading
startUploading: () => Promise<void>;
Interfaces
interface ApiError
interface ApiError extends Error {}
interface ConfigMetadata
interface ConfigMetadata {}
property contentLength
contentLength?: number;
Set the length of the file being uploaded.
property contentType
contentType?: string;
Set the content type of the incoming data.
index signature
[key: string]: any;
interface Encryption
interface Encryption {}
interface ErrorWithCode
interface ErrorWithCode extends Error {}
property status
status: number;
interface GoogleInnerError
interface GoogleInnerError {}
property reason
reason?: string;
interface QueryParameters
interface QueryParameters {}
property contentEncoding
contentEncoding?: string;
property ifGenerationMatch
ifGenerationMatch?: number;
property ifGenerationNotMatch
ifGenerationNotMatch?: number;
property ifMetagenerationMatch
ifMetagenerationMatch?: number;
property ifMetagenerationNotMatch
ifMetagenerationNotMatch?: number;
property kmsKeyName
kmsKeyName?: string;
property predefinedAcl
predefinedAcl?: PredefinedAcl;
property projection
projection?: 'full' | 'noAcl';
property userProject
userProject?: string;
interface RetryOptions
interface RetryOptions {}
property autoRetry
autoRetry?: boolean;
property maxRetries
maxRetries?: number;
property maxRetryDelay
maxRetryDelay?: number;
property retryableErrorFn
retryableErrorFn?: (err: ApiError) => boolean;
property retryDelayMultiplier
retryDelayMultiplier?: number;
property totalTimeout
totalTimeout?: number;
interface UploadConfig
interface UploadConfig {}
property apiEndpoint
apiEndpoint?: string;
The API endpoint used for the request. Defaults to
storage.googleapis.com
. **Warning**: If this value does not match the pattern *.googleapis.com, an emulator context will be assumed and authentication will be bypassed.
property authClient
authClient?: { request: <T>( opts: GaxiosOptions ) => Promise<GaxiosResponse<T>> | GaxiosPromise<T>;};
If you want to re-use an auth client from google-auto-auth, pass an instance here. Defaults to GoogleAuth and gets automatically overridden if an emulator context is detected.
property authConfig
authConfig?: GoogleAuthOptions;
The GoogleAuthOptions passed to google-auth-library
property bucket
bucket: string;
The name of the destination bucket.
property chunkSize
chunkSize?: number;
Create a separate request per chunk.
Should be a multiple of 256 KiB (2^18). We recommend using at least 8 MiB for the chunk size.
https://cloud.google.com/storage/docs/performing-resumable-uploads#chunked-upload
property configPath
configPath?: string;
Where the gcs-resumable-upload configuration file should be stored on your system. This maps to the configstore option by the same name.
property customRequestOptions
customRequestOptions?: GaxiosOptions;
For each API request we send, you may specify custom request options that we'll add onto the request. The request options follow the gaxios API: https://github.com/googleapis/gaxios#request-options.
property file
file: string;
The name of the destination file.
property generation
generation?: number;
This will cause the upload to fail if the current generation of the remote object does not match the one provided here.
property key
key?: string | Buffer;
A customer-supplied encryption key. See https://cloud.google.com/storage/docs/encryption#customer-supplied.
property kmsKeyName
kmsKeyName?: string;
Resource name of the Cloud KMS key, of the form
projects/my-project/locations/global/keyRings/my-kr/cryptoKeys/my-key
, that will be used to encrypt the object. Overrides the object metadata'skms_key_name
value, if any.
property metadata
metadata?: ConfigMetadata;
Any metadata you wish to set on the object.
property offset
offset?: number;
The starting byte of the upload stream, for resuming an interrupted upload. See https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload#resume-upload.
property origin
origin?: string;
Set an Origin header when creating the resumable upload URI.
property params
params?: QueryParameters;
Specify query parameters that go along with the initial upload request. See https://cloud.google.com/storage/docs/json_api/v1/objects/insert#parameters
property predefinedAcl
predefinedAcl?: PredefinedAcl;
Apply a predefined set of access controls to the created file.
property private
private?: boolean;
Make the uploaded file private. (Alias for config.predefinedAcl = 'private')
property public
public?: boolean;
Make the uploaded file public. (Alias for config.predefinedAcl = 'publicRead')
property retryOptions
retryOptions?: RetryOptions;
Configuration options for retrying retryable errors.
property uri
uri?: string;
If you already have a resumable URI from a previously-created resumable upload, just pass it in here and we'll use that.
property userProject
userProject?: string;
If the bucket being accessed has requesterPays functionality enabled, this can be set to control which project is billed for the access of this file.
Type Aliases
type CreateUriCallback
type CreateUriCallback = (err: Error | null, uri?: string) => void;
type PredefinedAcl
type PredefinedAcl = | 'authenticatedRead' | 'bucketOwnerFullControl' | 'bucketOwnerRead' | 'private' | 'projectPrivate' | 'publicRead';
Package Files (1)
Dependencies (8)
Dev Dependencies (17)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/gcs-resumable-upload
.
- Markdown[](https://www.jsdocs.io/package/gcs-resumable-upload)
- HTML<a href="https://www.jsdocs.io/package/gcs-resumable-upload"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3909 ms. - Missing or incorrect documentation? Open an issue for this package.