1.0.26 • Published 2 years ago

@404-software/s3-upload v1.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago