Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

744
Views
Vue display an image from firebase cloud storage blob

Im building a product lookup repository, users will scan a product barcode which will then return data about the product and a picture of the product to be displayed.

Right now for testing purposes I have set up a firebase storage bucket, with one image uploaded. Im have successfully been able to retrieve the image by calling the firebase storage api, but I cant seem to display it in my Vue app. I cant seem to find the proper documentation for this on firebase docs, as their example uses plain js and html.

My code to display the image:

<template>
  <div class="container">
    <div class="row">
      <div class="col">
        <image v-if="image!==null" :src="image"></image>
      </div>
    </div>
  </div>
</template>

The script that runs when the page is mounted and it will get the image from the storage bucket and display it.

<script>
import firebase from "firebase";
export default {
  name: "ProductPage",
  data: () => {
    return {
      image: null
    };
  },
  mounted() {
    firebase
      .storage()
      .ref("test/1234-1.jpg")
      .getDownloadURL()
      .then(url => {
        const xhr = new XMLHttpRequest();
        xhr.responseType = "blob";
        xhr.onload = event => {
          this.image = xhr.response;
          event.preventDefault();
        };
        xhr.open("GET", url);
        xhr.send();
      })
      .catch(error => {
        // Handle any errors
        console.log(error);
      });
  }
};
</script>

I know the api call works because when I check the developer console in chrome, i can see the image in preview on the api call in the networks tab. I just cant seem to display it in vue.

It stores the image as blob?

enter image description here

I have added the responses as requested: enter image description here

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The problem might be with Vue displaying Blob. Try:

xhr.onload = event => {
  this.image = URL.createObjectURL(xhr.response);
  event.preventDefault();
};

Here the URL.createObjectURL should create a reference to the Blob.

over 4 years ago · Santiago Trujillo Report

0

The problem lies not in the blob, but the vue tag to display the image. Instead of <image> we use <img> like this:

<img v-if="image !== null" :src="image" class="img-circle" alt="Services">
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!