Skip to content

Instantly share code, notes, and snippets.

View mujtabashamas's full-sized avatar
🎯
Focusing

Mujtaba Shamas mujtabashamas

🎯
Focusing
View GitHub Profile
@mujtabashamas
mujtabashamas / S3.js
Last active August 23, 2024 12:09
S3 Service file to perform tasks on the S3
// Usage
const S3 = require("./s3.service");
const uploadImage = async (image) => {
if (image.includes("base64")) {
let rawFileData = image;
let fileData = rawFileData.replace(/^data:image\/\w+;base64,/, "");
var buffer = Buffer.from(fileData, 'base64');
let type = image.split(';')[0].split('/')[1];
const newFileName = `${uuidv4()}.${type}`;