gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 01:02:26 24 4
gpt4 key购买 nike

我开发了一个 Android 应用程序,它使用 Google 应用程序引擎作为服务器并且运行良好。现在我想将图像从我的设备上传到谷歌云存储并从存储中检索到我的设备。我在互联网上阅读了很多关于谷歌云存储和数据存储的博客,但我不知道如何在 android 中实现它。

最佳答案

对于安卓,建议使用Firebase Storage以简化流程。

Firebase Storage stores your files in a Google Cloud Storage bucketshared with the default Google App Engine app, making them accessiblethrough both Firebase and Google Cloud APIs.

Implementation path:

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

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

  3. Upload or Download. Upload or download tonative 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com