aws-s3-upload-ash
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -71,3 +71,3 @@ "use strict"; | ||
key: `${this.config.dirName ? this.config.dirName + "/" : ""}${fileName}`, | ||
location: `${url}/${this.config.dirName ? this.config.dirName + "/" : ""}${fileName}`, | ||
location: `${url}${this.config.dirName ? `${this.config.dirName}/` : ""}${fileName}`, | ||
status: data.status | ||
@@ -74,0 +74,0 @@ }); |
{ | ||
"name": "aws-s3-upload-ash", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Open Source Module to Upload your Media and files into AWS S3 Bucket directly from Front-end", | ||
@@ -5,0 +5,0 @@ "main": "dist/aws-s3-upload-ash.js", |
124
README.md
@@ -10,4 +10,5 @@ # aws-s3-upload-ash | ||
## How to use(youtube) | ||
* How to use with React = | ||
* How to use with Angular = | ||
* How to use with React/Next.js = | ||
* How to use with Angular(12) = | ||
* How to use with Vue = | ||
# How get | ||
@@ -30,118 +31,11 @@ | ||
## ***Uploading to S3 with bucket public*** | ||
## React using Next.js | ||
- https://github.com/ismaelash/aws-s3-upload-nextjs | ||
```js | ||
import AWSS3UploadAsh from 'aws-s3-upload-ash'; | ||
## Angular 12 | ||
- https://github.com/ismaelash/aws-s3-upload-angular12 | ||
const config = { | ||
bucketName: 'bucketName', | ||
dirName: 'media', /* optional - when use: e.g BUCKET_ROOT/dirName/fileName.extesion */ | ||
region: 'us-east-1', | ||
accessKeyId: process.env.accessKeyId, | ||
secretAccessKey: process.env.secretAccessKey, | ||
s3Url: 'https://bucketName.s3.amazonaws.com/' | ||
} | ||
## Vue | ||
- https://github.com/ismaelash/aws-s3-upload-vue | ||
// if you bucket is public, you need of config | ||
const S3CustomClient = new AWSS3UploadAsh(config); | ||
const newFileNameWithExtesion = 'myPdf.pdf'; | ||
//file: File - required | e.g input html type file | ||
//contentType: string | required e.g application/pdf | ||
//presignedURL: string | optional | ||
//newFileName: string | optional e.g myImage.png | ||
//acl: string | optional default public-read | ||
// if you use presignedURL, not need newFileName and acl parameters, can be undefined | ||
S3CustomClient | ||
.uploadFile(file, "application/pdf", undefined, newFileNameWithExtesion, undefined) | ||
.then(data => console.log(data)) | ||
.catch(err => console.error(err)) | ||
/** | ||
* | ||
* { | ||
* bucket: "bucketName", | ||
* key: "media/myPdf.pdf", | ||
* location: "https://bucketName.s3.amazonaws.com/media/myPdf.pdf", | ||
* status: 204 | ||
* } | ||
* | ||
*/ | ||
}); | ||
``` | ||
## ***Uploading to S3 with presignedURL*** | ||
```js | ||
import AWSS3UploadAsh from 'aws-s3-upload-ash'; | ||
// if you use presignedURL, dont need config on AWSS3UploadAsh constructor | ||
const S3CustomClient = new AWSS3UploadAsh(); | ||
//file: File - required | e.g input html type file | ||
//contentType: string | required e.g application/pdf | ||
//presignedURL: string | optional | ||
//newFileName: string | optional e.g myImage.png | ||
//acl: string | optional default public-read | ||
// if you use presignedURL, not need newFileName and acl parameters, can be null | ||
S3CustomClient | ||
.uploadFile(file, "application/png", "presignedlURL", undefined, undefined) | ||
.then(data => console.log(data)) | ||
.catch(err => console.error(err)) | ||
/** | ||
* Response se you use presignedURL parameter | ||
* { | ||
* Response: { | ||
* status: 200, | ||
* body: "Upload complete" | ||
* } | ||
* } | ||
*/ | ||
}); | ||
``` | ||
## ***Uploading to S3 with bucket public and without directory*** | ||
```js | ||
import AWSS3UploadAsh from 'aws-s3-upload-ash'; | ||
const config = { | ||
bucketName: 'bucketName', | ||
region: 'us-east-1', | ||
accessKeyId: process.env.accessKeyId, | ||
secretAccessKey: process.env.secretAccessKey, | ||
s3Url: 'https://bucketName.s3.amazonaws.com/' | ||
} | ||
// if you bucket is public, you need of config | ||
const S3CustomClient = new AWSS3UploadAsh(config); | ||
const newFileNameWithExtesion = 'myVideo.mp4'; | ||
//file: File - required | e.g input html type file | ||
//contentType: string | required e.g application/pdf | ||
//presignedURL: string | optional | ||
//newFileName: string | optional e.g myImage.png | ||
//acl: string | optional default public-read | ||
// if you use presignedURL, not need newFileName and acl parameters, can be null | ||
S3CustomClient | ||
.uploadFile(file, "video/mp4", undefined, newFileNameWithExtesion, undefined) | ||
.then(data => console.log(data)) | ||
.catch(err => console.error(err)) | ||
/** | ||
* | ||
* { | ||
* bucket: "bucketName", | ||
* key: "myVideo.mp4", | ||
* location: "https://bucketName.s3.amazonaws.com/myVideo.mp4", | ||
* status: 204 | ||
* } | ||
* | ||
*/ | ||
}); | ||
``` | ||
## ***Deleting an existing file into directory in your bucket public*** | ||
@@ -148,0 +42,0 @@ |
@@ -79,3 +79,3 @@ import { dateYMD, xAmzDate } from "./Date"; | ||
key: `${this.config.dirName ? this.config.dirName + "/" : ""}${fileName}`, | ||
location: `${url}/${this.config.dirName ? this.config.dirName + "/" : ""}${fileName}`, | ||
location: `${url}${this.config.dirName ? `${this.config.dirName}/` : ""}${fileName}`, | ||
status: data.status | ||
@@ -82,0 +82,0 @@ }); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3
23853
129