I use Firebase Storage to upfile
. But it does not work
THIS IS MY CODE.
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference sto
Using putStream() is the the recommended way for most files instead of putFile()
(for local files on the device) like so:
InputStream stream = new FileInputStream(new File(pathToYourFile)));
UploadTask uploadTask = imageFileStorageReference.putStream(stream);
You can't use putFile()
with an HTTP type Uri
. According to the documentation, you're supposed to use it to upload a local file.
If you want to upload a file to Storage that exists somewhere else referenced by an HTTP URL
, you'll have to download that file first, store it locally, then upload it.
This Sorted me out, All I needed to do was to update the firebase-storage lib.
In my case it was 'com.google.firebase:firebase-storage:16.4.0'
and after updating it to 'com.google.firebase:firebase-storage:17.0.0'
everything start working fine again.
May be this is the wrong path bug but in my case resolve this here is the example
i use this code then i received error
public static StorageReference getChildProfileStorage(String vid){
StorageReference storageReference= FirebaseStorage.getInstance().getReference();
storageReference.child("ParentDataStore").child(CurrentUser.getInstance().getEmail())
.child("ChildDataStore").child(vid);
return storageReference;
}
here is the line that solve my problem
public static StorageReference getStudentProfileStorage(String vid){
StorageReference storageReference= FirebaseStorage.getInstance().getReference("ParentDataStore")
.child("StudentDataStore").child(vid).child("profile");
return storageReference;
}
For me it working properly if the upload file is no symbols such +
, @
, #
, $
make sure the file name is only number, letters, period, and underscore.
The key to solving this problem is to enable Storage in the app's permissions. You should follow these steps:
Settings -> Apps -> AppName -> Permissions -> Enable Storage
Remember that the file should exist on the device.