About saving PDF and other files to firebase storage

How do I upload a PDF file to firebase storage?
I can upload image files to firebase storage by referring to the tutorials in the forum, but when I upload a file such as a pdf, I cannot open it. I’ve been trying to upload image files all day today.
I’ve been trying all day and no luck.
Please help me.
I’m using automatic translation, so the text may not be correct.

Are you appending the ?alt=media to the end of the URL when you try to view it with Webview or PDF Preview?

The data uploaded to firebase is named PDF
but the file is missing.
If it’s a jpeg or png, I can check the file capacity in firebase storage, but if I upload a pdf, it empties the capacity.

Are you getting an error when you upload? What are you using to upload? Are you using Upload Files flow function?

The upload will be successful.
When I check the uploaded file in firebase storage, the name is registered, but the size is empty.
UploadFiles is used for uploading.

How do you select the file? Do you use Pick Files ?

I did a test here and my PDF file uploaded fine. Are you sure your file path is correct when you select the file?

Yes I am using pick files.


At the end of your Url you dont need to put ENCODE_FOR_URL around it, and you do not put + “?alt=media”

You only add the “?alt=media” when you are wanting to GET or Open it.

All your URL should look like is this:
https://firebasestorage.googleapis.com/v0/b/project name.appspot.com/o/” + outputs[“Pick files”].files[0].name

1 Like

It works “almost fine”.

I can upload PDF files without problem but:

Once uploaded the type is: “application/x-www-form-urlencoded” instead of “application/pdf”

So, when I want to visualize the file instead the browser download it.

There is a way to upload PDF as “application/pdf” type ???

My code in upload is:

[SET_KEY(pageVars.PDF_file, "uploadUrl","https://firebasestorage.googleapis.com/v0/b/*MYAPPPROJECT*/o/"+appVars.empresa_rfc+"%2F"+pageVars.year_declaracion+"_"+pageVars.mes_declaracion+"_"+pageVars.tipo_declaracion+"_"+pageVars.id_cliente+"_"+pageVars.nombre_cliente+".pdf")] 

Did you actually figure out, how to set the contentType to .pdf ?
image

Currently I use the component “UPLOAD FILES” inluded in Market Place. I don’t see how to set the type.

This behaviour only occure when I upload from Web, when I upload from the App all is fine.

According to the google cloud docs (Uploading objects  |  Cloud Storage  |  Google Cloud), the content type can be specified in the header like this:

image

It sets the content type correctly for native as well for web app:

1 Like

Thanks a lot, I will tried it.

It’s works fine. Thanks a lot. @stayfoolish

hello john ,
can you send me and tutorials links to upload pdf files on storage . i have tried but on pdf preview component i am getting error "unable to load ". and i am not able to upload pdf file on storage .