
Product
Announcing Bun and vlt Support in Socket
Bringing supply chain security to the next generation of JavaScript package managers
@bubojs/uploader-aws-s3
Advanced tools
This uploader allows you to use AWS S3 protocol.
declaration of a client instance AWS S3 version 3
import { S3 } from '@aws-sdk/client-s3';
import { S3Uploader } from '@bubojs/uploader-aws-s3';
const s3Bucket = new S3({
endpoint: process.env.S3_ENDPOINT,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
},
region: process.env.S3_REGION,
});
export const uploader = new S3Uploader({
bucket: s3Bucket,
bucketName: process.env.S3_BUCKET_NAME,
folderName: process.env.S3_FOLDER_NAME,
});
This example uses the 3 functions of the S3 uploader.
import { uploader } from './config'
import { Controller, BeforeMiddleware, Post, Body } from '@bubojs/api'
@Controller()
class TestController {
/**
* upload route with form-data body
* Body: {
* file: đź“„
* }
*/
@BeforeMiddleware(
uploader.buildUploadEndpoint({ authorizedExtensions: ['jpeg', 'png']})
)
@Post('/')
async uploadRoute(@Body('file') filename: string) {
console.log('uploaded file')
return {}
}
/**
* download route
* Params: {
* key: 'filename.jpeg'
* }
*/
@Get(':key', { bodyFormat: BodyFormat.AUTO, rawHandler: true })
downloadRoute() {
return uploader.buildDownloadEndpoint({
retrieveKeyCallback: async (req: any) => {
return req.params.key;
},
});
}
/**
* download route
* Params: {
* key: 'filename.jpeg'
* }
*/
@Delete(':key', { rawHandler: true })
deleteRoute() {
return uploader.buildDeleteEndpoint({
retrieveKeyCallback: async (req: any) => {
return req.params.key;
},
});
}
To save a file, the buildUploadEndpoint function is used as the middleware of the route. The file is uploaded using the S3 client on the AWS servers. Once the file is online, we replace the file in the body object with the file name with its file extension. It is possible to add these options:
The function allows to create a file download route, we use the rawHandler option in our custom route to be able to pass the constructor of the download endpoint
Options:
The function allows you to delete the file
Options:
FAQs
Unknown package
We found that @bubojs/uploader-aws-s3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.