Download backend/src/services/storageService.js from Shiva7706/BlueFin: direct link, hf CLI and curl.
- Browser
- Download file 813 Bytes
-
https://huggingface.co/spaces/Shiva7706/BlueFin/resolve/main/backend/src/services/storageService.js
- Command line
-
hf download hf://spaces/Shiva7706/BlueFin/backend/src/services/storageService.js
-
curl -L -o storageService.js https://huggingface.co/spaces/Shiva7706/BlueFin/resolve/main/backend/src/services/storageService.js
813 Bytes
| import fs from "fs"; | |
| import path from "path"; | |
| import config from "../config.js"; | |
| import supabase from "../lib/supabase.js"; | |
| function saveFileToDisk(jobId, fileBuffer, filename) { | |
| const folderPath = path.join(config.sharedTmpPath, jobId); | |
| fs.mkdirSync(folderPath, { recursive: true }); | |
| const filePath = path.join(folderPath, filename); | |
| fs.writeFileSync(filePath, fileBuffer); | |
| return filePath; | |
| } | |
| async function uploadToSupabase(jobId, filePath, fileName) { | |
| const fileBuffer = fs.readFileSync(filePath); | |
| const storagePath = `${jobId}/${fileName}`; | |
| const { error } = await supabase.storage | |
| .from("intelli-credit-uploads") | |
| .upload(storagePath, fileBuffer, { upsert: true }); | |
| if (error) throw new Error(error.message); | |
| return storagePath; | |
| } | |
| export { saveFileToDisk, uploadToSupabase }; | |