Google的Firebase是否支持视频存储?我打算上传视频并希望按需下载。我从Firebase开始。是否有任何其他API或服务提供类似的功能?
答案 0 :(得分:3)
当然,你可以在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();
}
});
}
}
答案 1 :(得分:1)
Firebase有一个Firebase Storage产品,允许您存储任意文件。
它不提供任何视频特定功能,但如果您只想存放和检索视频文件,它将会起作用。