Fork me on GitHub

Class base.blob.Blob


Defined in: blob.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
base.blob.Blob(cont, attrs)

Blob class.

Field Summary
Field Attributes Field Name and Description
 

Container object.

 

Blob name.

Method Summary
Method Attributes Method Name and Description
 
del(options)

Delete a blob.

 
get(options)

Get blob data (and metadata).

 
getToFile(filePath, options)

Get blob data to file.

 
head(options)

HEAD blob (check blob exists and return metadata).

 
put(options)

Put blob data (and metadata).

 
putFromFile(filePath, options)

Put blob data from file.

Event Summary
Event Attributes Event Name and Description
 
del_end(results, meta)

Completion event ('end').

 
del_error(err)

Error event ('error').

 
get_data(chunk, meta)

Data event ('data').

 
get_end(results, meta)

Completion event ('end').

 
get_error(err)

Error event ('error').

 
head_end(results, meta)

Completion event ('end').

 

Error event ('error').

 
put_end(results, meta)

Completion event ('end').

 
put_error(err)

Error event ('error').

Class Detail
base.blob.Blob(cont, attrs)

Blob class.

Parameters:
{base.Container} cont
Container object.
{Object} attrs
Attributes.
{string} attrs.name
Name.
{string} attrs.created
Creation date.
{string} attrs.lastModified
Last modified date.
{number} attrs.size
Byte size of object.
{string} attrs.etag
ETag.
Field Detail
{base.blob.Container} container

Container object.


{string} name

Blob name.

Method Detail

Delete a blob.

Events

Not Found Blobs

This method emits 'end' and not 'error' for a not found blob, reasoning that it becomes easier to have multiple deletes at the same time. Moreover, AWS S3 doesn't return a 404, so we can't really even detect this (although Google Storage does).

On end, result.notFound is returned that at least for Google Storage indicates if the blob didn't exist.

Parameters:
{Object} options Optional
Options object.
{Object} options.headers Optional
Raw headers to add.
{Object} options.cloudHeaders Optional
Cloud provider headers to add.
{Object} options.metadata Optional
Cloud metadata to add.
Returns:
{request.AuthenticatedRequest} Request object.

{stream.ReadStream} get(options)

Get blob data (and metadata).

Events

Parameters:
{Object} options Optional
Options object.
{string} options.encoding Optional
Encoding to use (if set, a string will be passed to 'data' or 'end' instead of array of Buffer objects).
{bool} options.validate Optional, Default: false
Validate?
{Object} options.headers Optional
Raw headers to add.
{Object} options.cloudHeaders Optional
Cloud provider headers to add.
{Object} options.metadata Optional
Cloud metadata to add.
Returns:
{stream.ReadStream} Readable cloud stream object.

{request.DummyRequest} getToFile(filePath, options)

Get blob data to file.

Note

Just a wrapper around a writable file stream and a GET. Must still call end() to invoke.

Events

Parameters:
{string} filePath
Path to file.
{Object} options Optional
Options object.
{string} options.encoding Optional
Encoding to use.
{Object} options.headers Optional
Raw headers to add.
{Object} options.cloudHeaders Optional
Cloud provider headers to add.
{Object} options.metadata Optional
Cloud metadata to add.
Returns:
{request.DummyRequest} Request object.

HEAD blob (check blob exists and return metadata).

Events

Parameters:
{Object} options Optional
Options object.
{Object} options.headers Optional
Raw headers to add.
{Object} options.cloudHeaders Optional
Cloud provider headers to add.
{Object} options.metadata Optional
Cloud metadata to add.
Returns:
{request.AuthenticatedRequest} Request object.

{stream.WriteStream} put(options)

Put blob data (and metadata).

Events

Parameters:
{Object} options Optional
Options object.
{string} options.encoding Optional
Encoding to use.
{Object} options.headers Optional
Raw headers to add.
{Object} options.cloudHeaders Optional
Cloud provider headers to add.
{Object} options.metadata Optional
Cloud metadata to add.
Returns:
{stream.WriteStream} Writable cloud stream object.

{request.DummyRequest} putFromFile(filePath, options)

Put blob data from file.

Note

Just a wrapper around a readable file stream and a PUT. Must still call end() to invoke.

Events

Parameters:
{string} filePath
Path to file.
{Object} options Optional
Options object.
{string} options.encoding Optional
Encoding to use.
{Object} options.headers Optional
Raw headers to add.
{Object} options.cloudHeaders Optional
Cloud provider headers to add.
{Object} options.metadata Optional
Cloud metadata to add.
Returns:
{request.DummyRequest} Request object.
Event Detail
del_end(results, meta)

Completion event ('end').

Note: Callback indicates the object no longer exists.

Parameters:
{Object} results
Results object.
{base.blob.Blob} results.blob
Blob object.
{boolean} results.notFound
True if object was not found.
{Object} meta
Headers, meta object.
{Object} meta.headers Optional
HTTP headers.
{Object} meta.cloudHeaders Optional
Cloud provider headers.
{Object} meta.metadata Optional
Cloud metadata.

del_error(err)

Error event ('error').

Parameters:
{Error|errors.CloudError} err
Error object.

get_data(chunk, meta)

Data event ('data').

Parameters:
{Buffer|string} chunk
Data chunk.
{Object} meta
Headers, meta object.
{Object} meta.headers Optional
HTTP headers.
{Object} meta.cloudHeaders Optional
Cloud provider headers.
{Object} meta.metadata Optional
Cloud metadata.

get_end(results, meta)

Completion event ('end').

Parameters:
{Object} results
Results object.
{base.blob.Blob} results.blob
Blob object.
{Object} meta
Headers, meta object.
{Object} meta.headers Optional
HTTP headers.
{Object} meta.cloudHeaders Optional
Cloud provider headers.
{Object} meta.metadata Optional
Cloud metadata.

get_error(err)

Error event ('error').

Parameters:
{Error|errors.CloudError} err
Error object.

head_end(results, meta)

Completion event ('end').

Parameters:
{Object} results
Results object.
{base.blob.Blob} results.blob
Blob object.
{Object} meta
Headers, meta object.
{Object} meta.headers Optional
HTTP headers.
{Object} meta.cloudHeaders Optional
Cloud provider headers.
{Object} meta.metadata Optional
Cloud metadata.

head_error(err)

Error event ('error').

Parameters:
{Error|errors.CloudError} err
Error object.

put_end(results, meta)

Completion event ('end').

Parameters:
{Object} results
Results object.
{base.blob.Blob} results.blob
Blob object.
{Object} meta
Headers, meta object.
{Object} meta.headers Optional
HTTP headers.
{Object} meta.cloudHeaders Optional
Cloud provider headers.
{Object} meta.metadata Optional
Cloud metadata.

put_error(err)

Error event ('error').

Parameters:
{Error|errors.CloudError} err
Error object.