0

Background I need to upload large product inventory to indexeddb on client side so that I can perform some offline operations. They json file size could be as large as 50 MB. So I uploaded the json file to google firebase storage with the intention to fetch the storage file, read the json and add them to indexeddb.

Question

what is the best way to fetch and read the file from google storage ?

Here is my fetch code

var fileUrl ="https://firebasestorage.googleapis.com/v0/b/konstant-ccbcc.appspot.com/o/storeid.json?alt=media&token=8d56ba73-331e-452e-b0d4-e552264feee3"

function loadJSON() {

fetch(fileUrl)
  .then(function(resp){
    return resp.json()
  })
  .then(function(data){
    console.log(data)
  })

}

this is error I am getting

Fetch API cannot load URL scheme must be "http" or "https" for CORS request. Uncaught (in promise) TypeError: Failed to fetch at loadJSON

e.iluf
  • 1,389
  • 5
  • 27
  • 69
  • When I go to that site it returns ```{ "error": { "code": 404, "message": "Not Found. Could not access bucket test-ccbcc.appspot.com", "status": "ACCESS_BUCKET" } }``` is this what you want? I'm doubting it –  Nov 23 '20 at 22:15
  • @JonahG I have added the actual file url – e.iluf Nov 23 '20 at 22:34

1 Answers1

0

The storage file is not accessible publicly. Add allUsers with Viewer permissions to the file permissions or add authentication to the request. Configure CORS, see Firebase Storage and Access-Control-Allow-Origin

Julian Kleine
  • 1,539
  • 6
  • 14