load (assetType, assetId, dataFormat) {
    // console.log("loading from cloud storage for firebase");
    const asset = new Asset(assetType, assetId, dataFormat)
    
    switch (assetType) {
      case AssetType.ImageBitmap:
      case AssetType.ImageVector:
        return this.firebaseStorage.ref().child(`${assetId}.${dataFormat}`)
          .getDownloadURL()
          .then(
            url => new Promise((resolve, reject) => {
              nets({method: 'get', url}, (err, resp, body) => {
                // body is a Buffer
                if (err || Math.floor(resp.statusCode / 100) !== 2) {
                  resolve(null)
                } else {
                  asset.setData(body, dataFormat)
                  resolve(asset)
                }
              })
            }),
            () => Promise.reject()
          )
      default:
        return Promise.resolve(null)
    }
  }
/**
   * Fetches an asset from Cloud Firestore for Firebase, if possible. Aims to
   * mirror the implementation of WebHelper.load in scratch-storage as much as
   * possible, including the use of nets.
   * @function load
   * @param {AssetType} assetType - The type of asset to fetch.
   * @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
   * @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
   * @return {Promise.<Asset>} A promise for the contents of the asset.
   */
Fetches an asset from Cloud Firestore for Firebase, if possible. Aims to
mirror the implementation of WebHelper.load in scratch-storage as much as
possible, including the use of nets.
@function load
@param {AssetType} assetType - The type of asset to fetch.
@param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
@param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
@return {Promise.} A promise for the contents of the asset.
Fetches an asset from Cloud Firestore for Firebase if possible . Aims to mirror the implementation of WebHelper . load in scratch - storage as much as possible including the use of nets . @function load @param { AssetType } assetType - The type of asset to fetch . @param { string } assetId - The ID of the asset to fetch : a project ID MD5 etc . @param { DataFormat } dataFormat - The file format / file extension of the asset to fetch : PNG JPG etc . @return { Promise . } A promise for the contents of the asset .
load (assetType, assetId, dataFormat) {
    const asset = new Asset(assetType, assetId, dataFormat)
    switch (assetType) {
      case AssetType.ImageBitmap:
      case AssetType.ImageVector:
        return this.firebaseStorage.ref().child(`${assetId}.${dataFormat}`)
          .getDownloadURL()
          .then(
            url => new Promise((resolve, reject) => {
              nets({method: 'get', url}, (err, resp, body) => {
                if (err || Math.floor(resp.statusCode / 100) !== 2) {
                  resolve(null)
                } else {
                  asset.setData(body, dataFormat)
                  resolve(asset)
                }
              })
            }),
            () => Promise.reject()
          )
      default:
        return Promise.resolve(null)
    }
  }
load ( assetType , assetId , dataFormat ) { const asset = new Asset ( assetType , assetId , dataFormat ) switch ( assetType ) { case AssetType . ImageBitmap : case AssetType . ImageVector : return this . firebaseStorage . ref ( ) . child ( ` ${ assetId } ${ dataFormat } ` ) . getDownloadURL ( ) . then ( url => new Promise ( ( resolve , reject ) => { nets ( { method : 'get' , url } , ( err , resp , body ) => { if ( err || Math . floor ( resp . statusCode / 100 ) !== 2 ) { resolve ( null ) } else { asset . setData ( body , dataFormat ) resolve ( asset ) } } ) } ) , ( ) => Promise . reject ( ) ) default : return Promise . resolve ( null ) } }
Fetches an asset from Cloud Firestore for Firebase, if possible.
Fetches an asset from Cloud Firestore for Firebase if possible .
// console.log("loading from cloud storage for firebase"); // body is a Buffer