gpt4 book ai didi

ios - 云存储服务,什么,如何以及哪些?

转载 作者:可可西里 更新时间:2023-11-01 03:09:03 25 4
gpt4 key购买 nike

在某些方面,我猜你可以说我正在创建类似于 iOS 应用程序“Vine”的东西。允许用户上传视频供其他人观看的社交网络。我的整个项目已经准备就绪,我正在使用名为 Parse 的数据库服务,但那里的存储空间不多,如果你想扩大规模,它会变得昂贵。我想我可以使用我已经拥有的数据库,并且让“视频”的 sql 表有一个链接到实际视频文件的 URL 列。我一直在寻找数据存储服务,并找到了谷歌的“云存储”。

如果可能的话,我真正想要的是像这样的用例:

  1. 客户端应用有一个视频可以上传。
  2. 将视频文件上传到 some-cloud-service.com/myCompany/videoNameID.mp4
  3. 将此 URL 存储在数据库中“视频对象”的 URL 字段中。
  4. 当其他用户获取视频列表时,他们会得到一组名称和 URL
  5. 当用户想要播放某个视频时,从表中的 URL 中获取它。

我一直在想我可以使用云存储作为我的应用程序上传和访问文件的地方。我一直在查看 Google 云存储的 API 和文档,但其中有太多我没有用的东西,而且我大部分都不明白。我开始认为“云存储”不是我想的那样。我只需要一个地方来直接从 iOS 应用程序(以及后来的网站)上传潜在的大量大文件。 Parse 提供的数据存储服务是完美的,但规模非常有限。我知道它有可能变得昂贵。从阅读this的价格谷歌服务,它看起来既便宜又正是我需要的,但我不明白,如果可能的话,我应该如何使用它来使用我的“凭据”直接上传文件,并接收一个 URL 作为文件结束位置的返回上。

我可以为此使用 Google 的云存储吗?或者是其他东西?还是我完全误解了如何使用 Cloud Storage?

最佳答案

实际上,Google 服务的 Objective-C 包装器库在这里有非常详细的文档: https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Preparing_to_Use_the_Library

它告诉您这个包装器库是根据底层 JSON API 自动生成的。所以所有 GTLStorage... 类都将模仿 Google Storage 的 JSON API。执行实际 API 调用的类是 GTLQueryStorage。

如果您查看该 JSON 文档,您会发现有一个用于将数据存储到桶中的对象类:https://developers.google.com/storage/docs/json_api/v1/#Objects上传新对象的方法是'insert'

回到 GTLQueryStorage.h 文件,您会找到相应的 Objective-C 方法来将新对象插入到您的存储桶中:

// Method: storage.objects.insert
// Stores new data blobs and associated metadata.
// Required:
// bucket: Name of the bucket in which to store the new object. Overrides the
// provided object metadata's bucket value, if any.
// Optional:
// ifGenerationMatch: Makes the operation conditional on whether the object's
// current generation matches the given value.
// ifGenerationNotMatch: Makes the operation conditional on whether the
// object's current generation does not match the given value.
// ifMetagenerationMatch: Makes the operation conditional on whether the
// object's current metageneration matches the given value.
// ifMetagenerationNotMatch: Makes the operation conditional on whether the
// object's current metageneration does not match the given value.
// name: Name of the object. Required when the object metadata is not
// otherwise provided. Overrides the object metadata's name value, if any.
// projection: Set of properties to return. Defaults to noAcl, unless the
// object resource specifies the acl property, when it defaults to full.
// kGTLStorageProjectionFull: Include all properties.
// kGTLStorageProjectionNoAcl: Omit the acl property.
// Upload Parameters:
// Accepted MIME type(s): */*
// Authorization scope(s):
// kGTLAuthScopeStorageDevstorageFullControl
// kGTLAuthScopeStorageDevstorageReadWrite
// Fetches a GTLStorageObject.
+ (id)queryForObjectsInsertWithObject:(GTLStorageObject *)object
bucket:(NSString *)bucket
uploadParameters:(GTLUploadParameters *)uploadParametersOrNil;

所以你应该:

  • 分配一个 GTLServiceStorage 实例
  • 将您的 API key 设置为该对象
  • 使用上面的类方法为要使用正确的存储桶保存的对象实例化一个 GTLQueryStorage 对象
  • 创建一个执行查询的服务票证,并获取一个完成处理程序来处理完成(成功、错误情况)。

关于ios - 云存储服务,什么,如何以及哪些?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18293618/

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