Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving compressed video to Firebase #27

Open
ladislavturanyi opened this issue Aug 20, 2017 · 2 comments
Open

Saving compressed video to Firebase #27

ladislavturanyi opened this issue Aug 20, 2017 · 2 comments

Comments

@ladislavturanyi
Copy link

Hi, I'm trying to save compressed video to Firebase Storage, but I'm getting error No content provider.
I'm getting sourceUri from data.getData and destinationUri is: mStorageReference = FirebaseStorage.getInstance().getReference().child("VideoFile");

Do you have any suggestion, where I'm making mistake? Thank you for any help.

` @OverRide
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_PICK_VIDEO && resultCode == RESULT_OK && data != null) {
Uri filepath = data.getData();
final String name = "VIDEO" + filepath.getLastPathSegment().toString() + ".mp4";

        StorageReference videoRef = mStorageReference.child(name);
        String compressPath = null;
        
        try {
            compressPath = SiliCompressor.with(getApplicationContext()).compressVideo(filepath.toString(), String.valueOf(mStorageReference));
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

        
        videoRef.putFile(Uri.parse(compressPath)).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Uri downloadedUrl = taskSnapshot.getDownloadUrl();
                String url = downloadedUrl.toString();
                getDownloadedUrl(downloadedUrl);
                uploadToDatabase(name, url, databaseReferenceString);
            }

`

and here is my logcat:

08-20 18:56:53.148 8388-8551/com.example.admin.databaseproject E/StorageException: StorageException has occurred. An unknown error occurred, please check the HTTP result code and inner exception for server response. Code: -13000 HttpResult: 0
08-20 18:56:53.148 8388-8551/com.example.admin.databaseproject E/StorageException: No content provider: gs:/firechat-99dd1.appspot.com/VideoFile/VIDEOvideo%3A26296.mp4/VIDEO_20170820_185653.mp4 java.io.FileNotFoundException: No content provider: gs:/firechat-99dd1.appspot.com/VideoFile/VIDEOvideo%3A26296.mp4/VIDEO_20170820_185653.mp4 at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1066) at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:921) at android.content.ContentResolver.openInputStream(ContentResolver.java:646) at com.google.firebase.storage.UploadTask.<init>(Unknown Source) at com.google.firebase.storage.StorageReference.putFile(Unknown Source) at com.example.admin.databaseproject.MainActivity.onActivityResult(MainActivity.java:165) at android.app.Activity.dispatchActivityResult(Activity.java:6235) at android.app.ActivityThread.deliverResults(ActivityThread.java:3584) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3631) at android.app.ActivityThread.access$1300(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5268) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

@larrytech7
Copy link
Contributor

i think you need to look at the overloaded method compressVideo and see to it that you are passing the correct parameters. I see in your compression line that the source and destination files have some issues especially the destination directory that's why firebase rejects it because it is not properly formatted. Check the compressVideo method documentation to understand it. Also try printing out the output file destination from the compressVideo

@Tourenathan-G5organisation
Copy link
Owner

@ladislavturanyi was your problem solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants