Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/space/routes/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import express from 'express';
var bill = express.Router();
// Imports your configured client and any necessary S3 commands.
import { PutObjectCommand } from "@aws-sdk/client-s3";
import { s3Client } from ".././client.js";
import multer from 'multer';
import ShortUniqueId from 'short-unique-id';
//Instantiate
const uid = new ShortUniqueId({ length: 10 });
// const multer = require('multer')
const storage = multer.memoryStorage()
const upload = multer({ storage: storage })
var bucket="jiffp";
bill.post("/courier_bill",upload.single('file'), async (req, res, next) => {
try {
var file=req.file;
var file_name=uid()+".xlsx";
let bucketParams = {
Bucket: bucket,
Key: "courier/bill/"+file_name,
Body: file.buffer,
ContentType: file.mimetype,
ACL: "public-read",
};
var re=await insert(bucketParams);
res.json({
message: 'File uploaded successfully',
file_name : file_name
});
} catch (err) {
console.error('Error processing upload:', err);
res.status(500).json({ error: 'Failed to upload file', details: err.message });
}
});
const insert = async (bucketParams) => {
try {
const data = await s3Client.send(new PutObjectCommand(bucketParams));
console.log(
"Successfully uploaded object: " +
bucketParams.Bucket +
"/" +
bucketParams.Key
);
return data;
} catch (err) {
console.log("Error ", err.message);
return "error";
}
};
export { bill }
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0056 ]-- |