HOW TO UPLOAD PDF / ANY FILE TO FIREBASE | ANDROID | IN JAVA
ฝัง
- เผยแพร่เมื่อ 31 ต.ค. 2024
- Hello friends, welcome to the first tutorial of "Advanced Android" Playlist. Here we will use Android Studio to learn how to upload PDF / Any File to FireBase using FireBase Storage and FireBase Real-time Database.
Notes:
For pdf : intent.setAction("application/pdf");
For docx : intent.setAction("docx/*);
For images: intent.setAction("images/*");
For audio : intent.setAction("audio/*);
For video: intent.setAction("video/*");
Follow the tutorial to learn how to do properly.
The language used is java and the IDE is Android Studio.
Watch the tutorial until the end to learn from Scratch and please Like, Comment & Subscribe to get more videos on useful and both important topics. ;-)
Thank You.
Instagram : / sdev_0709
Facebook : / sayan.dutta.3958
use tasksnapshot,getMetadata().getReference().getDownloadUrl().toString(); for getDownloadUrl() error
E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.android.gms.internal.zzand: Please sign in before trying to get a token.
i am getting this error while uploading url to realtime database
try this:
Task task = taskSnapshot.getMetadata().getReference().getDownloadUrl();
after that attach addOnSuccessListener again for task object like this:
task.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(Uri uri) {
String url = uri.toString(); //here u can get your url
}
here is my code: github.com/Kaushal-Top5699/PDF-UPLOADING-FIREBASE?files=1 check if it works for you!
@@kaushaltopinkatti8860 hi bro can you send me the code source please this's my email: bouzal.oussama02@gmail.com
Before. Getdownload just include. Getstorage()
oussama bouzal
I have sent you a mail please check sorry for late reply!😅🙏
sir, if it wasn't for you, idk how i'll manage to get my project done.. really thank you sir..
if you provide all tutorial in android studio , i'm sure everyone can be a master in android studio.. that's just how good and detail your explaination is.. please keep it up sir !
could you please provide me the MainActivity code?? I couldn't get my file uploaded in firebase..
I just watched a 45 min long video teaching me how to do complex ass things on the shittiest coding platform out there with the most horrible syntaxes known to man and at no point, I felt overwhelmed. You are the best teacher on youtube hands down.
It means a lot... Glad it helped youu...!! 😁
yr sayan dutta bro behtreen kaam hy please firebase pr or bhi vedios bnao... Firebase update hogia hy or net pr jitni vedios mil ri hain sb purany version ki hain... or itna detail me koi bhi ni smjhata jitna best ap smjha rhy ho please carry on great work man.. i really appreciate your hardwork...
Sir, Excellent tutorial. I have never seen such a great class of this complicated area with full explanation.
Thanks.
Your explanation is too good. I watched many tutorials but your's one is the best. Thanks for the video. Please upload more...
Excellent precise tutorial! Clear audio, clear video, concise app! I watched many tutorials for uploading and receiving files on 🔥firebase but this was simply the best! Now watching your video on retrieving the files from firebase
Keep up the good work sayan da 🍺
PS: You earned my subscription buddy😁
Man i got to say...your a very good teacher! your details in explaining its superb am looking forward to next tuts well done
My files are not uploading in the firebase... getting "failed to upload". could you please provide me your mainactivity code?
Thanx for the tutorial... U rock.. No other tutorials available regarding the topic for java thanx...
Sir one doubt.. If I upload the file/pdf from my mobile to the firebase will the uploaded file be available to download for other users of my android app.. Or will it be seen only on my mobile.. Pls help
Nice explanation line by line very nice
This guy makes the best tutorials!
superb
Very detailed tutorial indeed. Thanks you sir, for uploaded this tutorial. cheers!
Thank you so much for sharing and explaining in details
Bro, This one is the most useful and awesome video I have ever seen. Please do more.
Thanx brother, glad you liked it!!
Awesome tutorial, thank you very much.
It was very useful ! Thank you very much
Go on 👍👍
what if I want upload a csv file? Should I use intent.setAction("csv/*); ?
Fantastic! Amazing tutorial..
I tried your code by when I select a pdf and click upload the app closes.
Cool Bro!...Keep up the good work.
Thanks bro......
got errors:
StorageException has occurred
app is closing..
Thanks a lot, it's working fine but have one issue after selecting a file from the device the textview showing some number instead of file name. Is there anything I have to change in the code to display file name
Very good tutorial. Thanx man
The Best... Great. Thanks
Hello sir, why the name in notification.setText(Uri.getLastPathSegment().toString) shows number in the actual page? I use the fragment
Спасибо за обучалку. Ребят если кто сталкнулся с проблемой, что приложение не грузит pdf файлы, я решил ее следующим образом
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
//check whether user had selected a file or not (ex:pdf)
if(requestCode==86 && data != null){ //убрал условие && requestCode==RESULT_OK приложение заработало
pdfUri = data.getData();//return the uri of selected file...
notification.setText("A file is selected:" + data.getData().getLastPathSegment());
}
else{
Toast.makeText(MainActivity.this,"Please select a file",Toast.LENGTH_SHORT).show();
}
}
thank you sir.
there is no video on this topic.
Hi Sayan,
i plan to put a fingerprint authentication if user wanted to download the file on the firebase storage. do you have any idea on where to put the fingerprint authentication layer?
@Sayan Dutta sir.. I am getting blank page after pressing fetch button.. I have checked Minifest file...pls help..
awesome
How can the name of the uploaded file be changed so that the user is able to identify the files... In short is there a way to change the name of the uploaded files.. Pls help!!
Thank you sir..it really helped me!!
if we want to upload an .csv file than we used the commend (intent.setAction(csv/*);) ? answer plz .
and sir if we install this app to different mobile phones and save the data in database with different identity of every mobile(Every mobile must have different database storage tab) than what type of changing i must be done?
plz help me to resolve it.
waiting for your response bhai.
thanks in advance.
Exactly what I was looking for.... Amazing tutorial
Upload more videos sir .i just subscribed
thanks a lot for the video
when i click "select file" button the app does not ask for permission. please tell me what can i do.
use dexter library for managing permissions.
Sir my mobile version is v6 ... To main konsa version select karun per
You are awesome..
agar pdf ke nam se file firebase me storage pe save karna ho to kya kre................
In uploadeFile() method can't use String url=taskSnapshot. getDownloadUrl().toString();
it's old way to do that.need help
Nice brother
I want to upload .xml file on firebase , which extension should I use !
Hey bro I tried your code everything works fine. But when I hit upload it stays at 0% and doesn't upload. If theres any solution please contact me
Help!!!
How can we store text file on firebase and then read the content inside the text file in our app. In short how can i upload a .txt file on firebase and retrieve the content from it in android app?
I love u man !!
Sir there is an error
Manifest.permission.READ_EXTERNAL_STORAGE)
in above .its not working so please help
For docx : intent.setAction("docx/*);
For images: intent.setAction("images/*");
For audio : intent.setAction("audio/*);
For video: intent.setAction("video/*"); bro unable to use these features...shouldd we change somewhere else in the code?
Sir, error message comming for
getDownloadUrl in taskSnapshot
Hello am getting an error, "No file selected" after selecting a file.
Same here
it's been a year, did you get any solution?
@@Eli-kw2mz what is the solution?
Thank u sir for making this videos
sir i have a one problem download path not save in realtimedatabse can you help me
File uploaded to the storage, but in realtime database it is not shown. Could you please help me to solve this?
i want to set the file name as the original file name (the one on my device) then what to do?
Sayan Dutta Bro I got issue of error like File Not Found plz help me bro I go changed String url=storageRefrence.GetDownloadurl(). ToString(); still I'm getting File not found plz help I have to submit my project plz bro plz some one help me I'm getting stressed bcoz of this plz help me guys..... Plz...... 🙏
how to upload two different files under the same root child.. for example I want to upload pdf and image at the same time..
how can i download tht file store in storage using the LINK from database. plz help??
No Activity found to handle Intent { act=android.intent.action.GET_CONTENT typ=audiofile } can you please solve as soon as possible
I tried to implement this code in my application and it was successful. But if i select file from recent section then, data.getData().getLastPathSegment() returns a 6 digit number. In this case how will get the original filename ?
JAY SHAH you can get the whole path segement and not the last path segement separately, and substring the portion which is necessary
I can't upload it. It said that it is not successfully uploaded. can you help me?
Sir I want to show all the uploaded PDF thumbnail in my app and when click on it it opens in my app without helping Google drive. Please help me....
I am having an error that when I try to open this screan of uploandig the pdf file my app just close. Can someone help me ?
Facing same issue
When I upload a file, the TextView changes to "msf:24" instead of the file name. And then the upload fails.
Did you find the solution?
You should dismiss the progress dialog on success and on failure my friend :)
@@whoozthedev514 how can the "a file is selected: random file name" can be set back to the default "no files selected" text on successfully uploading the file
@@whoozthedev514 I tried doing that but on clicking the upload button the uploading process starts even when the textview says no files selected.
@@whoozthedev514 doesn't work 😪
Bro can you tell me how to implement recommender system in android app? I want to recommend the pdf files to the users. How can i do that?
File Cannot be uploaded to realtime database it is showing error as "E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.android.gms.internal.zzand: Please sign in before trying to get a token."
Hello All work is done. But it fail to upload. Can u tell me what happen?
thanx
I don't know why, but when I upload a doc, my netspeed gets reduced somehow, and doc overall doesn't gets uploaded.
Any idea why so?
when i set the intent type to "images/*" its not able to pick any image.All the images got disabled...i cant click on them.Help plz!!
Please can you help me how to hide any file or pdf from gallery in this app.. You create
filename got changed while uploading. What can we do so that the file name remains the same as we selected?
Sir i m getting an error stating 'User does not have permission to access this object's when upload button is clicked.Need your help
Hey buddy, my getDownloadUrl is showing error ,pls tell me what to do, I tried to apply solutions from comments but unable to do it correctly.
Please tell me what to do
hii...if only one user is allowed to upload file and all others can only read.....what to do
Thank alot
Hello sir after uploading the files it shows in the storage but not in database
hello sir,
please make video on how to display all uploaded pdf files in thumbnails and
open it when clicks on it without downloading.. please sir please.
getDownloadUrl is missing in newer versions . any alternative of this??
String url = taskSnapshot.getStorage().getDownloadUrl().toString();
try this
I have tried to create an application that records audio, and then uploading it to firebase. The code which I used to record audio actually saves it to the phone storage. I tried to get the pathname of the audio stored and then converted it to Uri. And the rest I followed your code. So I have used the uploadFile function of your code. But my app says, 'not succesfully uploaded'.
@@whoozthedev514 my studio version is 2.2.3 . I cant find the logcat
@@whoozthedev514 StorageException has occured
The server has terminated the upload session
@Sayan Dutta I cant able to use taskSnapshot.getDownloadUrl.toString();
so i googled it there i found to use storageReference.getDownloadUrl.toString();
but it doesnt return the actual url instead it returns dome storage location of the file..
I'm using Android Studio 3.2.1.
Thanks In Advance.
same prob brother,, have u got any solutions ?? ty
Same problem🤦🏻♀️
You have same tutorial for firestore sir? Thank you. It would help a lot
+Sayan Dutta (SDEV 0709) Subscribed. Thank you so much sir.
How to uploaded image and pdf together in fire storage??
This was only for pdf file, right?
ROLI VERMA For other files see the description of the video, only small chnge needs to be done..
Hello sir, first of all thank you so much for making video on this topic. But when i'm compiling the code it shows me the error in storage=FirebaseStorage.getInstance(); What should i do ? everything is same as you taught in the video. please response ASAP. it's very important.
F:\TPO\FromSplashScreen\app\src\main\java\com\example
aghav\fromsplashscreen\CRT_Material.java:
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details.
or Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
# methods: 78384 > 65536
Message{kind=ERROR, text=Cannot fit requested classes in a single dex file. Try supplying a main-dex list.
# methods: 78384 > 65536, sources=[Unknown source file], tool name=Optional.of(D8)}
There are two errors.
error: non-static method getDownloadUrl() cannot be referenced from a static context
you just forgot to make it a local variable for it
Sayan thanks for tutorial. I wrote the code. It is working but, i can't select PDFs from SD CARD. Only Drive or Dropbox. Why?
Same problem here. Have anyone find out the solution?
intent.settype() is not working for anything other than pdf. Please help me I want csv and json file.
Ankit Goyal Surprisingly, Android does NOT support "json" (and "js" for javascript extension) as a MIME type. This is clear, for example, from the source codes of MimeUtils. Also you can use MimeTypeMap helper class and find out that:
MimeTypeMap.getSingleton().getMimeTypeFromExtension("json");
returns null;
The only most close MIME type that can be used instead of "application/json" is "application/octet-stream": it matches "*.json" files among other things, but a lot of other stuff as well. At least it filters out images, texts, music files and videos.
@@whoozthedev514 Thankyou so much brother for quick response and this lovely video. Found the solution to upload any type of file.
intent.setType("*/*);
This is working for every type of file.
Only one problem I am facing i.e. even if the file is successfully uploaded it is printing
File not successfully uploaded.
Don't know but everything is working completely filne, if you can help that will be really helpful for me.
Ankit Goyal check the placement of toast message, and also whether u r printing the correct message, sometimes silly mistakes cost a lot.
@@whoozthedev514 Yeaaah brotherr....Thank you so much brother.
hi i have a problem i can't manage to select a pdf file on an android phone yet i followed the tutorial
Thanks a lot it helped me and i already subscribed.. Need one more help if you can.. I just wanted to know if i can have different activities for different user. I have two types of user 1. student and 2. faculty how can i show different functionalities to different user.
Hey bro .. I m also working on this kind of project .. if you have found the answer to your question please .. tell me that.. thnks in advance
@@yash-5711 Hey Yash, I did like this I created 2 different buttons to sign in one for student and other for faculty and after that injust validated accordingly. If you need more help let me know
@@gadhiyapreet ohk thankyou .. if I encounter any more problem I'll ask you .. thanx buddy
and the rules for the firebase caules with bro?
How can I delete a specific file from the storage ?
what to use instead of progressDialog !
Cannot find taskSnapshot.getDownloadUrl() is not present
Plz send us source code ....
waht if i have to use both image and pdf?
Design your UI based on it, and the for both if these types use intent.setType as mentioned in description...
done
Unfortunately, there are changes in the latest version of android studio and as a result, this may not work.
Try to make video on how to delete any file which i have uploaded to storage in firebase by mistake
Thank you so much for this awesome tutorial! However I am getting some StorageException and the app crashes when I click the upload button. Please help, its urgent
Vishakha Laumas please see the logcat, and find the line no of within in your class files, from where its originating..
@@whoozthedev514 Solved it! Thank you
@@whoozthedev514 Sir, how do I find line no of within my class files? I didn't get it. Anyways it was a great tutorial but unfortunately my app crashes when I click the upload button
@@syajratuldurr161 Thanks, Check the error from the logcat when u click upload button... and for the line no problem u can just google..
can you help with how to assign an admin to an android app