npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

webiny-file-storage-s3

v1.13.0

Published

AWS S3 file-system storage driver for webiny-file-storage library

Readme

webiny-file-storage-s3

AWS S3 driver for webiny-file-storage interface.

Documentation

Table of Contents

About

This is the AWS S3 driver for webiny-file-storage. The driver allows you to store files to S3.

Get started

The S3 driver takes a config object defined by S3StorageDriverConfig flow type. The S3StorageDriverConfig takes the following parameters:

S3StorageDriverConfig = {
    bucket: string,             /* required */
    accessKeyId: string,        /* required */
    secretAccessKey: string,    /* required */
    region: string,             /* required */
    endpoint: string,           /* required */
    createDatePrefix: boolean,
    directory: string,
    publicUrl: string
};

Classes

S3StorageDriver

packages-utils/webiny-file-storage-s3/src/index.js:45-387

S3StorageDriver class instance is the AWS S3 driver for webiny-file-storage.

Examples

import S3StorageDriver from "webiny-file-storage-s3";
import type { S3StorageDriverConfig } from "webiny-file-storage-s3";

const params: S3StorageDriverConfig = {
    bucket: "TestBucket",
    accessKeyId: "AWS_AccessKeyId",
    secretAccessKey: "AWS_SecretAccessKey",
    region: "us-east-2",
    endpoint: "s3.us-east-2.amazonaws.com"
};

const s3Storage = new S3StorageDriver(S3StorageDriverConfig);
s3Storage.getFile("fileKey");
getFile

packages-utils/webiny-file-storage-s3/src/index.js:60-72

Returns the file and its content.

Parameters

  • key string This is the file identifier under which the file is stored.
  • options Object This is the list of additional parameters - defined by IFileStorageDriver, but not used in case of this driver.

Returns Promise<IFileData> IFileData object.

setFile

packages-utils/webiny-file-storage-s3/src/index.js:80-118

Writes the given file and returns final file key.

Parameters

  • key string This is the file identifier under which the file will be stored.
  • file IFileData This is the IFileData object containing the content and meta information.

Returns Promise<string> The final key under which the file is stored.

getMeta

packages-utils/webiny-file-storage-s3/src/index.js:125-137

Returns file meta information.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns Promise<Object> Object containing the file meta information.

setMeta

packages-utils/webiny-file-storage-s3/src/index.js:145-153

Sets file meta information. Tne new meta information is merged with the existing meta information.

Parameters

  • key string This is the file identifier under which the file is stored.
  • meta Object This is the object containing the new meta information that will be added to the file.

Returns Promise<boolean> Returns true if meta has been set successfully, otherwise false.

exists

packages-utils/webiny-file-storage-s3/src/index.js:160-166

Returns true if the file exists, otherwise false.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns Promise<boolean>

getKeys

packages-utils/webiny-file-storage-s3/src/index.js:177-212

Returns an array of all keys. In case of S3, the key parameter is used as a Prefix filter. Once the results matching this filter have been retrieved a regex match with filter param is applied and then all matching files are returned.

Parameters

  • key string This is the "Prefix" filter.
  • filter string (Optional) Additional regex filter that will be applied

Returns Promise<Array> Array of file keys that match the given filters.

delete

packages-utils/webiny-file-storage-s3/src/index.js:219-230

Delete the file.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns Promise<boolean> true if the file is deleted successfully, otherwise false.

rename

packages-utils/webiny-file-storage-s3/src/index.js:238-259

Rename the file.

Parameters

  • sourceKey string This is the new file key.
  • targetKey string This is the current file identifier under which the file is stored.

Returns Promise<boolean> true if the file is renamed successfully, otherwise false.

getURL

packages-utils/webiny-file-storage-s3/src/index.js:270-276

Returns the public file url. In case the publicUrl param is defined in the S3StorageDriverConfig the public url will return publicUrl+key. In case the publicUrl param is not defined, the method uses the endpoint and bucket param to form the public url.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns string Public URL.

getSize

packages-utils/webiny-file-storage-s3/src/index.js:284-297

Get file size in bytes.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns Promise<number> Number of bytes.

getTimeModified

packages-utils/webiny-file-storage-s3/src/index.js:305-316

Get file last modified time.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns Promise<number> Unix timestamp.

getContentType

packages-utils/webiny-file-storage-s3/src/index.js:324-332

Get file content type.

Parameters

  • key string This is the file identifier under which the file is stored.

Returns Promise<string> File content type.