Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/storage

Package Overview
Dependencies
Maintainers
9
Versions
2059
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/storage

Storage category of aws-amplify

  • 6.6.11-storage-browser-integrity.2a9053f.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
725K
decreased by-2.73%
Maintainers
9
Weekly downloads
 
Created

What is @aws-amplify/storage?

@aws-amplify/storage is a package that provides a simple and powerful way to manage user files and data in Amazon S3. It is part of the AWS Amplify library, which is designed to help developers build cloud-enabled applications. The package offers functionalities such as uploading, downloading, and managing files in S3, as well as configuring access levels and handling file metadata.

What are @aws-amplify/storage's main functionalities?

Upload a File

This feature allows you to upload a file to an S3 bucket. The code sample demonstrates how to upload a text file with the content 'Hello, world!' to S3 using the Storage.put method.

const { Storage } = require('@aws-amplify/storage');

async function uploadFile(file) {
  try {
    const result = await Storage.put('example.txt', file, {
      contentType: 'text/plain'
    });
    console.log('File uploaded successfully:', result);
  } catch (error) {
    console.error('Error uploading file:', error);
  }
}

uploadFile('Hello, world!');

Download a File

This feature allows you to download a file from an S3 bucket. The code sample demonstrates how to download a file named 'example.txt' from S3 using the Storage.get method and log its content.

const { Storage } = require('@aws-amplify/storage');

async function downloadFile() {
  try {
    const file = await Storage.get('example.txt', { download: true });
    console.log('File downloaded successfully:', file.Body.toString('utf-8'));
  } catch (error) {
    console.error('Error downloading file:', error);
  }
}

downloadFile();

List Files

This feature allows you to list all files in an S3 bucket. The code sample demonstrates how to list all files using the Storage.list method and log the result.

const { Storage } = require('@aws-amplify/storage');

async function listFiles() {
  try {
    const files = await Storage.list('');
    console.log('Files in bucket:', files);
  } catch (error) {
    console.error('Error listing files:', error);
  }
}

listFiles();

Delete a File

This feature allows you to delete a file from an S3 bucket. The code sample demonstrates how to delete a file named 'example.txt' from S3 using the Storage.remove method.

const { Storage } = require('@aws-amplify/storage');

async function deleteFile() {
  try {
    await Storage.remove('example.txt');
    console.log('File deleted successfully');
  } catch (error) {
    console.error('Error deleting file:', error);
  }
}

deleteFile();

Other packages similar to @aws-amplify/storage

FAQs

Package last updated on 17 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc