HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 云存储服务,什么,如何以及哪些?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在某些方面,我猜你可以说我正在创建类似于iOS应用程序’Vine’的东西.一个社交网络,允许用户上传视频供他人观看.我的整个项目已经准备就绪,我正在使用一个名为 Parse数据库服务,但那里的存储空间不大,如果你想扩展它,它会变得昂贵.我想我可以使用我已经拥有的数据库,并且让“Videos”的sql-table有一个链接到实际视频文件的URL列.我一直在寻找数据存储服务,并发现了谷歌的“云存储”.

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

>客户端应用已准备好上传视频.
>将视频文件上传到some-cloud-service.com/myCompany/videoNamEID.mp4
>将此URL存储在数据库中“视频对象”的URL字段中.
>当其他用户提取视频列表时,他们会获得一组名称和URL
>当用户想要播放某个视频时,请从表格中的URL中获取该视频.

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

我可以使用谷歌的云存储吗?或者是其他东西?或者我完全误解了如何使用云存储?

解决方法

实际上,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
上传新对象方法是“插入”

回到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密钥设置为该对象>使用上面的类方法为要使用正确存储桶保存的对象实例化GTLQueryStorage对象>创建一个服务票据,它执行查询并获得一个完成处理程序来处理完成(成功,错误情况).

大佬总结

以上是大佬教程为你收集整理的ios – 云存储服务,什么,如何以及哪些?全部内容,希望文章能够帮你解决ios – 云存储服务,什么,如何以及哪些?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。