In my code, there is a function that works with firebase storage to generate download URLs for uploaded files. Here's an example of the function:
uploadHandler(upload: Project) {
const storageRef = firebase.storage().ref();
const uploadTask = storageRef.child(`${this.basePath}/${upload.file.name}`).put(upload.file);
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
(snapshot: firebase.storage.UploadTaskSnapshot) => {
// handle upload progress
const snap = snapshot;
upload.progress = (snap.bytesTransferred / snap.totalBytes) * 100;
},
(error) => {
// handle upload failure
console.log(error);
},
() => {
// handle upload success
if (uploadTask.snapshot.downloadURL) {
upload.url = uploadTask.snapshot.downloadURL; // this is the URL variable
upload.name = upload.file.name;
this.fire.collection(`users/${this.auth.userId}/projects`).add( { photoURL: upload.url, file: upload.file.name, })
this.saveFileData(upload);
return;
} else {
console.error('No download URL found!');
}
},
);
}
Now, I would like to utilize the generated URL in another function where I have a parameter urlPath:string:
public accessZipFileContent(urlPath:string, pathInZip:string) {
getFileContentFromRemoteZip(urlPath, pathInZip, (content) => {
console.log(content);
});
}
}
How can I achieve this?