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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-aws3-manager

v0.0.3

Published

Pure JavaScript react native library for uploading, deleting, and retrieving from AWS S3

Downloads

8

Readme

react-native-aws3-manager

A React Native library for managing uploads, deletions, and retrievals from AWS S3 with enhanced features. Inspired by the react-native-aws3 package.

Why Choose react-native-aws3-manager?

react-native-aws3-manager offers several advantages over the react-native-aws3 package:

  • Maintained and Updated: Unlike react-native-aws3, which is no longer maintained, react-native-aws3-manager is actively maintained and regularly updated.
  • Enhanced Features: Includes additional functionalities such as the ability to delete objects and retrieve authenticated objects from AWS S3.
  • TypeScript Support: Fully written in TypeScript, providing better type safety and developer experience.
  • Improved Security: Utilizes crypto-js for added security features.
  • Better Documentation: Comprehensive and detailed documentation, including examples for all supported operations.

Description

react-native-aws3-manager provides an easy-to-use interface for uploading, deleting, and retrieving files from AWS S3 in React Native applications. This library leverages AWS SDK and offers additional features and security using crypto-js.

Installation

Using npm

To install the library and its dependencies, run:

npm install react-native-aws3-manager crypto-js aws-sdk

Using yarn

To install the library and its dependencies, run:

yarn add react-native-aws3-manager crypto-js aws-sdk

Usage

Uploading a File

To upload a file to AWS S3, use the put method provided by the library.

import { RNS3 } from "react-native-aws3-manager";

const file = {
  uri: "path-to-your-file",
  name: "file-name.jpg",
  type: "image/jpeg",
};

const options = {
  bucket: "your-bucket",
  region: "your-region",
  accessKey: "your-access-key",
  secretKey: "your-secret-key",
  successActionStatus: 201,
};

RNS3.put(file, options)
  .then((response) => {
    if (response.status !== 201) {
      throw new Error("Failed to upload image to S3");
    }
    console.log("Successfully uploaded file to S3:", response.body);
  })
  .catch((error) => {
    console.error("Error uploading file to S3:", error);
  });

Deleting a File

To delete a file from AWS S3, use the delete method provided by the library.

import { RNS3 } from "react-native-aws3-manager";

const options = {
  bucket: "your-bucket",
  region: "your-region",
  accessKey: "your-access-key",
  secretKey: "your-secret-key",
};

RNS3.delete("uploads/file-name.jpg", options)
  .then((response) => {
    if (response.status !== 204) {
      throw new Error("Failed to delete file from S3");
    }
    console.log("Successfully deleted file from S3");
  })
  .catch((error) => {
    console.error("Error deleting file from S3:", error);
  });

Retrieving a File

To retrieve a file from AWS S3, use the get method provided by the library.

import { RNS3 } from "react-native-aws3-manager";

const options = {
  bucket: "your-bucket",
  region: "your-region",
  accessKey: "your-access-key",
  secretKey: "your-secret-key",
};

RNS3.get("uploads/file-name.jpg", options)
  .then((response) => {
    if (response.status !== 200) {
      throw new Error("Failed to retrieve file from S3");
    }
    console.log("Successfully retrieved file from S3:", response.body);
  })
  .catch((error) => {
    console.error("Error retrieving file from S3:", error);
  });

API

RNS3.put(file, options)

Uploads a file to AWS S3.

file: Object containing uri, name, and type of the file. options: Object containing bucket, region, accessKey, secretKey, keyPrefix, and successActionStatus.

RNS3.delete(key, options)

Deletes a file from AWS S3.

key: String representing the key of the file to retrieve. options: Object containing bucket, region, accessKey, and secretKey.

RNS3.get(key, options)

Retrieves a file from AWS S3.

key: String representing the key of the file to retrieve. options: Object containing bucket, region, accessKey, and secretKey.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs, improvements, or new features.