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;








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 :)










share|improve this question






























    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 :)










    share|improve this question


























      0












      0








      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 :)










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 23:33









      kenwenkenwen

      1974 silver badges13 bronze badges




      1974 silver badges13 bronze badges

























          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
          );



          );













          draft saved

          draft discarded


















          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.



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해