Closed sumonshil closed 4 years ago
Add below code in your manifest.xml inside the application tag,add android:requestLegacyExternalStorage="true"
as well in manifest refer me and add this file provider
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_path" />
</provider>
I used it, but it still gives same error. I didn't understand please help
Use this
final StorageReference videoRef =storage.getReference().child("VideoPost").child("1").child("video/"+ uuid+"."+"mp4");
UploadTask uploadTask = videoRef.putFile(Uri.fromFile(new File(String.valueOf(selectedVideoUri))));
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
videoRef.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
Toast.makeText(context, "Video uploaded", Toast.LENGTH_SHORT).show();
String uploadedUrl = task.getResult().toString();
Log.d("TAG", "UploadedVideo::" + uploadedUrl);
}
});
}
})
thank you so much.........problem sloved
when i try to directly upload Uri in Storage, its show me an error like this.
2020-10-15 12:52:31.545 21431-22778/com.magica_technology.icon E/StorageException: No content provider: /storage/emulated/0/VIDEO/trimmed_video_0.mp4 java.io.FileNotFoundException: No content provider: /storage/emulated/0/VIDEO/trimmed_video_0.mp4 at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1675) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1505) at android.content.ContentResolver.openInputStream(ContentResolver.java:1189) at com.google.firebase.storage.UploadTask.<init>(UploadTask.java:131) at com.google.firebase.storage.StorageReference.putFile(StorageReference.java:240)
My code uploading code` reference= storage.getReference().child("VideoPost").child("1").child("video/"+ uuid+"."+getExtension()); reference.putFile(VUri) .addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {