Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
abstract-object-storage
Advanced tools
Collection of useful utilities for working with Google Cloud Storage.
The goal is to eventually add support for AWS S3 as well.
npm install --save abstract-object-storage
# or
yarn add abstract-object-storage
This module uses async await and therefore requires node >= 8.
process.env.GOOGLE_APPLICATION_CREDENTIALS = '<insert auth credentials here>'
const storage = require('abstract-object-storage').defaults({
bucket: 'my-test-bucket'
})
await storage.uploadFile({
key: 'test/example.jpg',
localPath: './example.jpg'
})
const buffer = await storage.downloadBuffer({
key: 'test/example.jpg'
})
// buffer should equal the contents of './example.jpg'
All methods take a generic Options Object which may specify auth, bucket, and file properties.
Storage authentication (gcs docs)
projectId
keyFilename
email
credentials
client_email
private_key
autoRetry
maxRetries
promise
Note that the preferred way of authenticating with GCS is to use the GOOGLE_APPLICATION_CREDENTIALS
environment variable, which case, nothing from this section is a required param to storage
.
Bucket (gcs docs)
bucket
- string, required name of bucket to operate againstFile (gcs docs)
key
- string, required name of file in bucket
to operate againstPath
path
- string, optional gs://
url including both bucket
and key
. Note that specifying a path
will override any bucket
or key
that is specified.This module uses the defaults pattern similar to node's popular request module.
storage.defaults(opts) => storage
This method returns a wrapper around the normal storage
api that defaults to whatever options you pass to it.
Note: You can call .defaults()
on the wrapper that is returned from storage.defaults
to add/override defaults that were previously defaulted.
Returns the length of the remote file specified by the given bucket
and key
.
storage.contentLength({ key }) => Promise<Number>
Copies one remote file to another file location. Note that both the source
and dest
files are specified via the common parameters specified above and will inherit from values specified on the storage defaults.
storage.copyFile(source, dest) => Promise
Downloads the remote file specified by the given bucket
and key
to a Buffer
.
storage.downloadBuffer({ key }) => Promise<Buffer>
Downloads the remote file specified by the given bucket
and key
to a readable stream.
storage.downloadStream({ key }) => ReadableStream
Downloads the remote file specified by the given bucket
and key
to a local file.
storage.downloadFile({ key, localPath }) => Promise
localPath
- string, required path of the destination fileReturns a signed url to access the remote file specified by the given bucket
and key
.
Note that the returned url has a TTL and may have ACLs applied to it.
storage.getSignedUrl({ key }) => Promise<String>
options
- object, optionaloptions.expires
- number | string | date, optional expiration date for the url (defaults to 2 days from Date.now()
)options.action
- string, optional acl (gcs docs)Moves one remote file to another file location. Note that both the source
and dest
files are specified via the common parameters specified above and will inherit from values specified on the storage defaults.
storage.moveFile(source, dest) => Promise
Uploads a buffer to the remote file specified by the given bucket
and key
.
storage.uploadBuffer({ key, buffer, metadata, options }) => Promise
buffer
- Buffer, required Buffer to uploadmetadata
- Object, optional resource metadata to be attached to the upload (gcs docs)options
- Object, optional additional options to customize the upload (gcs docs)Uploads the contents of a local file to the remote file specified by the given bucket
and key
.
storage.uploadFile({ key, localPath, metadata, options }) => Promise
localPath
- string, required path of the local source filemetadata
- Object, optional resource metadata to be attached to the upload (gcs docs)options
- Object, optional additional options to customize the upload (gcs docs)Note that uploadFile
defaults its resource metadata
to the content-type
and content-length
of the local file (via mime-types).
Uploads a readable stream to the file specified by the given bucket
and key
.
storage.uploadStream({ key, stream, metadata, options }) => Promise
stream
- stream, required readable stream to uploadmetadata
- Object, optional resource metadata to be attached to the upload (gcs docs)options
- Object, optional additional options to customize the upload (gcs docs)MIT © Travis Fischer
FAQs
Utilities for Google Cloud Storage
The npm package abstract-object-storage receives a total of 2 weekly downloads. As such, abstract-object-storage popularity was classified as not popular.
We found that abstract-object-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.