1.0.26 • Published 11 months ago
@404-software/s3-upload v1.0.26
About
This package makes uploading files to S3 very simple by providing helper functions
How to use
You can set the following environment variables. Alternatively, you can pass the config to the function directly.
S3_UPLOAD_BUCKET="Bucket name"
S3_UPLOAD_URL="Custom URL"
S3_UPLOAD_KEEP_ORIGINAL_URL="true|false"
S3_UPLOAD_KEEP_ORIGINAL_FILENAME="true|false"
# Only pick one, both work.
S3_UPLOAD_REGION="me-south-1" || AWS_REGION="AWS_SECRET"
S3_UPLOAD_ACCESS_KEY_ID="AWS_SECRET" || AWS_ACCESS_KEY_ID="AWS_SECRET"
S3_UPLOAD_SECRET_ACCESS_KEY="AWS_KEY" || AWS_SECRET_ACCESS_KEY="AWS_KEY"
Examples
import { uploadFile, deleteFile } from '@404-software/s3-upload'
const user = db.user.find(1)
// Upload new image
const imageUrl = await uploadFile({
folder: 'users-images',
file: newImage,
region: 'me-south-1',
config: {
bucket: 'MY-S3-BUCKET',
keepOriginalFilename: false.
keepOriginalUrl: true,
credentials: {
secretAccessKey: "AWS_SECRET",
accessKeyId: "AWS_KEY",
}
}, // ONLY if environment variables not set
})
// Delete old image
await deleteImage({ file: user.image }) // Key is extracted automatically from URL
1.0.26
11 months ago
1.0.25
11 months ago
1.0.24
11 months ago
1.0.23
1 year ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.19
1 year ago
1.0.18
1 year ago
1.0.17
1 year ago
1.0.16
1 year ago
1.0.15
1 year ago
1.0.14
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago