android - 如何将图像从安卓设备上传到谷歌云存储?

标签 android google-app-engine google-cloud-storage

我开发了一个 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:

  1. Integrate the Firebase Storage SDKs. Quickly include clients via Gradle, CocoaPods, or a script include.

  2. Create a Reference. Reference the path to a file, such as "images/mountains.png", to upload, download, or delete it.

  3. Upload or Download. Upload or download to native types in memory or on disk.

  4. 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/

相关文章:

java - 如何从Android使用谷歌应用程序引擎查询实体?

java - GWT + JDO + GAE,如何安排我的数据以提高性能

java - 部署后无法从Google云端存储上传和下载文件

javascript - 如何使用 Node.js Express 后端正确处理文件上传?

android - 为什么这个 Kotlin Coroutine 会卡住界面?

android - Phonegap 下载文件并保存在内部存储器中

python - 在 Google App Engine 中调试 Jinja2

google-app-engine - 部署应用引擎后的暂存文件桶

android - 为android项目创建Jar文件

java - 如何在java中格式化日期范围?