Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
3 views
v2js
Uploaded by
Ravi Teja
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download now
Download
Save v2js For Later
Download
Save
Save v2js For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
3 views
v2js
Uploaded by
Ravi Teja
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download now
Download
Save v2js For Later
Carousel Previous
Carousel Next
Save
Save v2js For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
const { Storage } = require('@google-cloud/storage');
exports.generate_thumb_data_v2 = async (file, context) => {
try {
console.log("Running v2 function...");
const gcsFile = file;
const storage = new Storage();
const sourceBucket = storage.bucket(gcsFile.bucket);
const finalBucket = storage.bucket('sp24-50100-rpillala-gj-final');
console.log(`File name: ${gcsFile.name}`);
console.log(`Content type: ${gcsFile.contentType}`);
// Check if the file exists
const [exists] = await sourceBucket.file(gcsFile.name).exists();
if (!exists) {
console.log(`File ${gcsFile.name} does not exist.`);
return;
}
console.log(`File ${gcsFile.name} exists in bucket ${sourceBucket.name}.
Continuing processing...`);
// Check content type
if (gcsFile.contentType !== 'image/jpeg' && gcsFile.contentType !==
'image/png') {
console.log('Invalid file type. Deleting from bucket.');
await sourceBucket.file(gcsFile.name).delete();
return;
}
// Create a new filename for the final image
const finalFileName = `${gcsFile.generation}.${gcsFile.contentType ===
'image/jpeg' ? 'jpg' : 'png'}`;
const tempFilePath = path.join(os.tmpdir(), finalFileName);
console.log(`Downloading file ${gcsFile.name} to ${tempFilePath}`);
// Download the original file
await sourceBucket.file(gcsFile.name).download({ destination:
tempFilePath });
console.log(`File downloaded to ${tempFilePath}`);
// Upload the file to the final bucket
await finalBucket.upload(tempFilePath, {
destination: finalFileName,
});
console.log(`File uploaded to final bucket`);
console.log("v2 function completed successfully.");
} catch (error) {
console.error("Error in v2 function:", error);
throw error;
}
};
You might also like
NodeJS Assignments
PDF
100% (3)
NodeJS Assignments
5 pages
الكود
PDF
No ratings yet
الكود
5 pages
v3js
PDF
No ratings yet
v3js
2 pages
11. FIle Upload to Firebase - Copy
PDF
No ratings yet
11. FIle Upload to Firebase - Copy
7 pages
Working Guilt File
PDF
No ratings yet
Working Guilt File
9 pages
Upload File From Local Disk To A Specific Box Folder in C#
PDF
No ratings yet
Upload File From Local Disk To A Specific Box Folder in C#
2 pages
5
PDF
No ratings yet
5
4 pages
ModuleSourceCodeCommitForReviewSteps
PDF
No ratings yet
ModuleSourceCodeCommitForReviewSteps
4 pages
Google Drive Files Report
PDF
No ratings yet
Google Drive Files Report
2 pages
VBS
PDF
No ratings yet
VBS
7 pages
APIs
PDF
No ratings yet
APIs
5 pages
Bypass Paywalls For Scientific Documentsv3.4.3
PDF
No ratings yet
Bypass Paywalls For Scientific Documentsv3.4.3
6 pages
AIT Practical2 (Parth)
PDF
No ratings yet
AIT Practical2 (Parth)
7 pages
Script - Forms - Novo 2 (1)
PDF
No ratings yet
Script - Forms - Novo 2 (1)
2 pages
Sorting Files
PDF
No ratings yet
Sorting Files
5 pages
Script - Forms - Mad
PDF
No ratings yet
Script - Forms - Mad
2 pages
Mongodb Tutorial To Store Unstructured Data
PDF
No ratings yet
Mongodb Tutorial To Store Unstructured Data
5 pages
Script - Forms - Mud
PDF
No ratings yet
Script - Forms - Mud
2 pages
Biggies Beans Hub (DONT CLICK)
PDF
No ratings yet
Biggies Beans Hub (DONT CLICK)
4 pages
Lab Manual Solution AWP 2025
PDF
No ratings yet
Lab Manual Solution AWP 2025
26 pages
Save 12
PDF
No ratings yet
Save 12
270 pages
message
PDF
No ratings yet
message
4 pages
Script - Forms - Novo 3 (ia)
PDF
No ratings yet
Script - Forms - Novo 3 (ia)
2 pages
haijiao
PDF
No ratings yet
haijiao
5 pages
firebase guide
PDF
No ratings yet
firebase guide
6 pages
Generator Trait
PDF
No ratings yet
Generator Trait
7 pages
63 NoideJS HTTP Url Querystring Filesystem Eventemitter Callback Funtion 06-03-2023
PDF
No ratings yet
63 NoideJS HTTP Url Querystring Filesystem Eventemitter Callback Funtion 06-03-2023
20 pages
NodeJS_File_Operations
PDF
No ratings yet
NodeJS_File_Operations
3 pages
(Fe) Walk On Walls Script Roblox
PDF
No ratings yet
(Fe) Walk On Walls Script Roblox
2 pages
Notes of Azure Data Bricks
PDF
No ratings yet
Notes of Azure Data Bricks
16 pages
Message
PDF
No ratings yet
Message
3 pages
Banking Guru 99
PDF
No ratings yet
Banking Guru 99
13 pages
Google Drive Codes
PDF
No ratings yet
Google Drive Codes
2 pages
ImportKeywordHighlightINI Py
PDF
No ratings yet
ImportKeywordHighlightINI Py
4 pages
Lecture # 5 Introduction To Node - Js (Part II) : by Dr. Sidra Sultana
PDF
No ratings yet
Lecture # 5 Introduction To Node - Js (Part II) : by Dr. Sidra Sultana
29 pages
Files and Streams
PDF
No ratings yet
Files and Streams
17 pages
Shell PHP
PDF
No ratings yet
Shell PHP
9 pages
A script to fetch all pagg
PDF
No ratings yet
A script to fetch all pagg
2 pages
Restore
PDF
No ratings yet
Restore
5 pages
v4js
PDF
No ratings yet
v4js
1 page
Java Servlet File Upload Example
PDF
No ratings yet
Java Servlet File Upload Example
5 pages
SFTP - Apex
PDF
No ratings yet
SFTP - Apex
7 pages
Node JS Modules
PDF
No ratings yet
Node JS Modules
6 pages
Yokohama Console & Fetch
PDF
No ratings yet
Yokohama Console & Fetch
3 pages
BadUSB - Exfill
PDF
No ratings yet
BadUSB - Exfill
2 pages
Code secret gold (1)
PDF
No ratings yet
Code secret gold (1)
2 pages
script
PDF
No ratings yet
script
16 pages
File Transfer Using Java Sockets
PDF
No ratings yet
File Transfer Using Java Sockets
7 pages
CN Lab6
PDF
No ratings yet
CN Lab6
6 pages
Untitled Script
PDF
No ratings yet
Untitled Script
8 pages
File Handling in C
PDF
No ratings yet
File Handling in C
19 pages
From Fastapi Import FastAPI, File,
PDF
No ratings yet
From Fastapi Import FastAPI, File,
4 pages
Pasted_Text_1740419010519
PDF
No ratings yet
Pasted_Text_1740419010519
4 pages
NtlmPasswordAuthenticator
PDF
No ratings yet
NtlmPasswordAuthenticator
2 pages
Headtrick Nova Atualizaçao
PDF
100% (1)
Headtrick Nova Atualizaçao
8 pages
Create A File With Hole in It
PDF
No ratings yet
Create A File With Hole in It
63 pages
Code Advancement
PDF
No ratings yet
Code Advancement
6 pages
Aim Busch
PDF
No ratings yet
Aim Busch
8 pages
papers (1)
PDF
No ratings yet
papers (1)
63 pages
NgRx SignalStore: An effortless solution for state management
From Everand
NgRx SignalStore: An effortless solution for state management
Abdelfattah Ragab
No ratings yet