2016-06-09 78 views
0

Google的Firebase是否支持視頻存儲?正在計劃上傳視頻並希望按需下載。我從Firebase開始。是否還有其他提供類似功能的API或服務?Firebase:視頻存儲

回答

1

Firebase具有Firebase Storage產品,允許您存儲任何任意文件。

它不提供任何特定於視頻的功能或功能,但如果您只是想擁有一個位置來存儲和檢索視頻文件,它將起作用。

2

當然你可以上傳視頻或任何在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(); 
      } 
     }); 
    } 
}