我开发了一个 Android 应用程序,它使用 Google 应用程序引擎作为服务器并且运行良好。 现在我想将图像从我的设备上传到谷歌云存储并从存储中检索到我的设备。 我在互联网上阅读了很多关于谷歌云存储和数据存储的博客,但我不知道如何在 android 中实现它。
最佳答案
对于安卓,建议使用Firebase Storage以简化流程。
Firebase Storage stores your files in a Google Cloud Storage bucket shared with the default Google App Engine app, making them accessible through both Firebase and Google Cloud APIs.
Implementation path:
Integrate the Firebase Storage SDKs. Quickly include clients via Gradle, CocoaPods, or a script include.
Create a Reference. Reference the path to a file, such as "images/mountains.png", to upload, download, or delete it.
Upload or Download. Upload or download to native types in memory or on disk.
Secure your Files. Use Firebase Storage Security Rules to secure your files.
例子:
StorageReference mStorageRef = FirebaseStorage.getInstance().reference().child("cloudstorage/path/to/file.jpg");
Uri file = Uri.fromFile(new File("local/path/to/file.jpg"));
UploadTask uploadTask = mStorageRef.putFile(file);
在 this sample 中查找更多信息.
关于android - 如何将图像从安卓设备上传到谷歌云存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39251173/