prago
prago

Reputation: 5413

Firebase : Video storage

Does Google's Firebase support video storage ? Am planning to upload video and want to download on-demand. I started with Firebase. Are there any other APIs or services that give a similar functionality ?

Upvotes: 0

Views: 4163

Answers (2)

satish gupta
satish gupta

Reputation: 31

Of course you can upload video or any files on firebase.

btnupload.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_GET_CONTENT);
            myIntent.setType("*/*");
            startActivityForResult(Intent.createChooser(myIntent,"Select File:-"),101);
        }
    });

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if(resultCode==RESULT_CANCELED)
    {
        // action cancelled
    }
    if(resultCode==RESULT_OK)
    {
        // Create a storage reference from our app
        StorageReference storageRef = storage.getReferenceFromUrl("gs://<<Your App Bucket Address>>");
        Uri uri = data.getData();
        StorageReference riversRef = storageRef.child("files/"+uri.getLastPathSegment());
        UploadTask uploadTask = riversRef.putFile(uri);

        // Register observers to listen for when the download is done or if it fails
        uploadTask.addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception exception) {
                // Handle unsuccessful uploads

                Toast.makeText(MainActivity.this, "Upload Failed", Toast.LENGTH_SHORT).show();
            }
        }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                // taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL.

                Toast.makeText(MainActivity.this, "Upload Success", Toast.LENGTH_SHORT).show();
            }
        });
    }
}

Upvotes: 3

Bryan Herbst
Bryan Herbst

Reputation: 67189

Firebase has a Firebase Storage offering that allows you to store any arbitrary files.

It doesn't offer any video-specific features or functionality, but it will work if you simply want to have a place to store and retrieve your video files.

Upvotes: 1

Related Questions