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

react-aws-s3-typescript

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-aws-s3-typescript - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

dist/index.d.ts

2

package.json
{
"name": "react-aws-s3-typescript",
"version": "1.0.1",
"version": "1.0.2",
"description": "Open source npm package to upload your files into AWS S3 Bucket directly using react(typescript template)",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -66,40 +66,43 @@ # react-aws-s3-typescript

/* uploadFile.ts */
import S3 from 'react-aws-s3-typescript';
import ReactS3Client from 'react-aws-s3-typescript';
import { s3Config } from './s3Config.ts';
/* Import s3 config object and call the constrcutor */
const s3 = new S3(s3Config);
const uploadFile = async () => {
/* Import s3 config object and call the constrcutor */
const s3 = new ReactS3Client(s3Config);
/* You can use the default directory defined in s3Config object
* Or you can a define custom directory to upload when calling the
* constructor using js/ts object destructuring.
*
* const s3 = new S3({
* ...s3Config,
* dirName: 'custom-directory'
* });
*
*/
/* You can use the default directory defined in s3Config object
* Or you can a define custom directory to upload when calling the
* constructor using js/ts object destructuring.
*
* const s3 = new ReactS3Client({
* ...s3Config,
* dirName: 'custom-directory'
* });
*
*/
const filename = 'filename-to-be-uploaded'; /* Optional */
const filename = 'filename-to-be-uploaded'; /* Optional */
/* If you do not specify a file name, file will be uploaded using uuid generated
* by short-UUID (https://www.npmjs.com/package/short-uuid)
*/
/* If you do not specify a file name, file will be uploaded using uuid generated
* by short-UUID (https://www.npmjs.com/package/short-uuid)
*/
try {
const res = await s3.uploadFile(file, filename);
s3.uploadFile(file, filename).then((res) => {
console.log(res);
/*
* {
* Response: {
* bucket: "bucket-name",
* key: "directory-name/filename-to-be-uploaded",
* location: "https:/your-aws-s3-bucket-url/directory-name/filename-to-be-uploaded"
* }
* }
*/
}).catch((err) => {
console.log(err);
})
console.log(res);
/*
* {
* Response: {
* bucket: "bucket-name",
* key: "directory-name/filename-to-be-uploaded",
* location: "https:/your-aws-s3-bucket-url/directory-name/filename-to-be-uploaded"
* }
* }
*/
} catch (exception) {
console.log(exception);
/* handle the exception */
}

@@ -114,17 +117,22 @@ /* End of uploadFile.ts */

/* deleteFile.ts */
import S3 from 'react-aws-s3-typescript';
import ReactS3Client from 'react-aws-s3-typescript';
import { s3Config } from './s3Config.ts';
/* Import s3 config object and call the constrcutor */
const s3 = new S3(s3Config);
const deleteFile = async () => {
/* Import s3 config object and call the constrcutor */
const s3 = new ReactS3Client(s3Config);
/* Define the filepath from the root of the bucket to the file to be deleted */
const filepath = 'directory-name/filename-to-be-deleted';
/* Define the filepath from the root of the bucket to the file to be deleted */
const filepath = 'directory-name/filename-to-be-deleted';
await s3.deleteFile(filepath).then((res) => {
console.log('File deleted');
}).catch((err) => {
console.log(err);
})
try {
await s3.deleteFile(filepath);
console.log('File deleted');
} catch (exception) {
console.log(exception);
/* handle the exception */
}
}
/* End of deleteFile.ts */

@@ -131,0 +139,0 @@ ```

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