Firebase functions - can't get Sharp to save file downloaded to function instanceIn Node.js, how do I “include” functions from my other files?Can't upload to google cloud or firebase storage bucket from nodejsfirebase function get download url after successfully save image to firebase cloud storageFirebase Storage and Cloud functions: how to load content from url and save into storage?Can't Override Content-Disposition to 'inline' in Firebase Storage with Admin SDK for Node.jsHow can I reference a GCP cloud storage object, from the firebase download link, using the Admin SDKFirebase Cloud Storage download url vs pathEfficient Firebase Storage image downloadHow to save Firebase Storage urls to FirestoreWrong MIME type after using sharp API with Firebase/Angular app
What is this "opened" cube called?
IList<T> implementation
LINQ Extension methods MinBy and MaxBy
ELI5 what is SMTChecker?
Why haven't the British protested Brexit as ardently as the Hong Kong protesters?
What is the chance of getting a Red Cabbage in year 1?
Who declared the Last Alliance to be the "last" and why?
How can I store milk for long periods of time?
How is the casino term "a high roller" commonly expressed in German?
Moscow SVO airport, how to avoid scam taxis without pre-booking?
What XY coordinate system goes with EGM96 when projecting elevation raster in ArcGIS Pro?
Why can't I get the argument count of a template function at compile-time?
Coupling two 15 Amp circuit breaker for 20 Amp
How to Flip Rotation from Positive to Negative?
How can I improve my formal definitions?
Received email from ISP saying one of my devices has malware
Padding a column of lists
Why do IR remotes influence AM radios?
What are ways to record who took the pictures if a camera is used by multiple people?
Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense
Ask one verbal question to figure out who is blind and who is mute among three persons
Is Borg adaptation only temporary?
Where should I draw the line on follow up questions from previous employer
How to understand payment due date for a credit card
Firebase functions - can't get Sharp to save file downloaded to function instance
In Node.js, how do I “include” functions from my other files?Can't upload to google cloud or firebase storage bucket from nodejsfirebase function get download url after successfully save image to firebase cloud storageFirebase Storage and Cloud functions: how to load content from url and save into storage?Can't Override Content-Disposition to 'inline' in Firebase Storage with Admin SDK for Node.jsHow can I reference a GCP cloud storage object, from the firebase download link, using the Admin SDKFirebase Cloud Storage download url vs pathEfficient Firebase Storage image downloadHow to save Firebase Storage urls to FirestoreWrong MIME type after using sharp API with Firebase/Angular app
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to convert specific images saved to Firebase storage as webp.
I'm able to download the image to the function instance
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import * as os from "os";
import * as path from "path";
admin.initializeApp();
const sharp = require("sharp");
const storage = admin.storage();
const bucket = storage.bucket();
const imageRef = data.storageRef;
const fileName = path.basename(imageRef);
const webpFileName = `$fileName.split(".").shift().webp`;
try
console.log("Downloading file");
const tempFilePath = path.join(os.tmpdir(), fileName);
const imageBuffer = await bucket.file(imageRef).download(destination: tempFilePath);
console.log(`Downloaded file to $tempFilePath`);
// save image as webp
const webpFile = sharp(imageBuffer).toFile(webpFileName);
console.log("Sharpening");
const webpRef = await bucket.upload(webpFile);
console.log(`Uploaded $webpRef`);
return imageRef;
catch (e)
console.log(`Error $e.message`);
return null;
I'm able to download the image but sharp is throwing an Unsupported input object error
Any suggestions? Thanks :)
node.js firebase sharp
add a comment |
I'm trying to convert specific images saved to Firebase storage as webp.
I'm able to download the image to the function instance
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import * as os from "os";
import * as path from "path";
admin.initializeApp();
const sharp = require("sharp");
const storage = admin.storage();
const bucket = storage.bucket();
const imageRef = data.storageRef;
const fileName = path.basename(imageRef);
const webpFileName = `$fileName.split(".").shift().webp`;
try
console.log("Downloading file");
const tempFilePath = path.join(os.tmpdir(), fileName);
const imageBuffer = await bucket.file(imageRef).download(destination: tempFilePath);
console.log(`Downloaded file to $tempFilePath`);
// save image as webp
const webpFile = sharp(imageBuffer).toFile(webpFileName);
console.log("Sharpening");
const webpRef = await bucket.upload(webpFile);
console.log(`Uploaded $webpRef`);
return imageRef;
catch (e)
console.log(`Error $e.message`);
return null;
I'm able to download the image but sharp is throwing an Unsupported input object error
Any suggestions? Thanks :)
node.js firebase sharp
add a comment |
I'm trying to convert specific images saved to Firebase storage as webp.
I'm able to download the image to the function instance
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import * as os from "os";
import * as path from "path";
admin.initializeApp();
const sharp = require("sharp");
const storage = admin.storage();
const bucket = storage.bucket();
const imageRef = data.storageRef;
const fileName = path.basename(imageRef);
const webpFileName = `$fileName.split(".").shift().webp`;
try
console.log("Downloading file");
const tempFilePath = path.join(os.tmpdir(), fileName);
const imageBuffer = await bucket.file(imageRef).download(destination: tempFilePath);
console.log(`Downloaded file to $tempFilePath`);
// save image as webp
const webpFile = sharp(imageBuffer).toFile(webpFileName);
console.log("Sharpening");
const webpRef = await bucket.upload(webpFile);
console.log(`Uploaded $webpRef`);
return imageRef;
catch (e)
console.log(`Error $e.message`);
return null;
I'm able to download the image but sharp is throwing an Unsupported input object error
Any suggestions? Thanks :)
node.js firebase sharp
I'm trying to convert specific images saved to Firebase storage as webp.
I'm able to download the image to the function instance
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import * as os from "os";
import * as path from "path";
admin.initializeApp();
const sharp = require("sharp");
const storage = admin.storage();
const bucket = storage.bucket();
const imageRef = data.storageRef;
const fileName = path.basename(imageRef);
const webpFileName = `$fileName.split(".").shift().webp`;
try
console.log("Downloading file");
const tempFilePath = path.join(os.tmpdir(), fileName);
const imageBuffer = await bucket.file(imageRef).download(destination: tempFilePath);
console.log(`Downloaded file to $tempFilePath`);
// save image as webp
const webpFile = sharp(imageBuffer).toFile(webpFileName);
console.log("Sharpening");
const webpRef = await bucket.upload(webpFile);
console.log(`Uploaded $webpRef`);
return imageRef;
catch (e)
console.log(`Error $e.message`);
return null;
I'm able to download the image but sharp is throwing an Unsupported input object error
Any suggestions? Thanks :)
node.js firebase sharp
node.js firebase sharp
asked Mar 27 at 23:33
kenwenkenwen
1974 silver badges13 bronze badges
1974 silver badges13 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388066%2ffirebase-functions-cant-get-sharp-to-save-file-downloaded-to-function-instanc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388066%2ffirebase-functions-cant-get-sharp-to-save-file-downloaded-to-function-instanc%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown