0

I am using firebase admin storage to upload images. On my computer the images look fine but after uploading them to firebase they look pixelated and blurry.

"firebase": "^9.6.9",
"firebase-admin": "^10.0.2",

enter image description here

here is my code. The downloadUrl is the one that looks blurry.

import { getStorage } from "firebase-admin/storage";
import { UploadResponse } from "@google-cloud/storage";

async function upload(localFilePath) {
  const uploadResp: UploadResponse = await getStorage()
    .bucket()
    .upload(localFilePath);

  // how can i use UploadResponse to determine a public download url?
  const downloadUrl = await uploadResp[0].getSignedUrl({
    action: "read",
    expires: "03-09-2491",
  });
  return downloadUrl;
}

Also there is no preview in firebase console Error Creating Access Token. I dont know if this is related.

enter image description here

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
Omar
  • 2,726
  • 2
  • 32
  • 65
  • The top portion of the image looks fine just like local version. Are you sure the images has totally loaded yet? – Dharmaraj Apr 04 '22 at 19:20
  • That is a good observation. Its true. But i dont know where in my code i need to wait. before making the downloadUrl? It must have something to do with upload completion. but they seem to stay in this bad state no matter how long i wait – Omar Apr 04 '22 at 19:21
  • Try checking the network tab in your browser dev tools and check if the image has loaded 100%. And maybe also try any other device. – Dharmaraj Apr 04 '22 at 19:23
  • My best guess would be that because Firebase storage is not a CDN it's sometimes taking that long. – Dharmaraj Apr 04 '22 at 19:34
  • I realized that it is not just a matter of waiting. Some images never get better. Waiting is not always the right answer. Maybe not using firebase storage is the answer – Omar Apr 04 '22 at 19:55

0 Answers0