Upload file to Google Cloud Storage

Hello :slight_smile:

For some reason I need metadata, sorry if it confused you, it wasn’t relevant in my example :slight_smile:
Soo yes, the method above works fine but… I need to remove a piece of the input file to make it “valiid”.

The thing is, upload a jpg image using the above code will result of having an image on GCS that is not openable, invalid. (you get the image icon but the image is broken)

The solution I found is to remove the begining of the file containing the infos of the file :slight_smile:

// ...
let fileContent = removeHeaderFromFile(productImage)
export function removeHeaderFromFile(input: string): string {
    let regex = new RegExp('data:(.+);(.+),');
    let r  = input.match(regex);
    if (r)
        console.log(r[0]); //=> "data:image/jpeg;base64,"
    input = input.replace(r[0], "")
    return input
}