Untitled
unknown
javascript
2 years ago
1.0 kB
8
Indexable
function getVideoThumbnail(file: FileData) {
return new Promise((resolve: Function, reject: Function) => {
const destPath = getNewNamePath(file.randomId);
const command = getCommand(file.path, destPath);
exec(command, (err: Error) => {
if (err) {
reject(err);
} else {
const fileStream = fs.createReadStream(destPath);
const uploadParams = {
Bucket: 'YOUR_S3_BUCKET_NAME',
Key: destPath,
ACL: 'public-read',
ContentType: 'image/jpeg', // Update with the appropriate content type
Body: fileStream,
StorageClass: 'STANDARD',
};
s3.upload(uploadParams, (uploadErr: AWS.AWSError, data: AWS.S3.ManagedUpload.SendData) => {
if (uploadErr) {
reject(uploadErr);
} else {
fs.unlink(destPath, () => {}); // Delete the local file after successful upload
resolve(data.Location);
}
});
}
});
});
}Editor is loading...