
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.