Sti*_*Sti 8 database cloud storage ios google-cloud-storage
在某些方面,我猜你可以说我正在创建类似于iOS应用'Vine'的东西.一个社交网络,允许用户上传视频供他人观看.我的整个项目已经准备好了,我正在使用一个名为Parse的数据库服务,但那里的存储空间不大,如果你想扩展它,它会变得昂贵.我想我可以使用我已经拥有的数据库,并且让"Videos"的sql-table有一个链接到实际视频文件的URL列.我一直在寻找数据存储服务,并找到了谷歌的"云存储".
如果可能的话,我真正想要的是这个用例:
some-cloud-service.com/myCompany/videoNameID.mp4我一直在想我可以使用云存储作为上传和访问我的应用程序文件的地方.我一直在浏览Google云端存储的API和文档,但是那里有很多我没用的东西,而且我对它的大部分都不了解.我开始认为"云存储"并不是我认为的那样.我只是需要一个地方来直接从iOS应用程序(以及后来的网站)上传潜在的大量大文件.Parse提供的数据存储服务非常完美,但尺寸非常有限.我知道它有可能变得昂贵.从阅读这个谷歌服务的价格,它看起来既便宜又正是我需要的,但我无法理解,如果可能的话,我应该如何使用它直接上传文件,使用我的"凭据",并接收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;
Run Code Online (Sandbox Code Playgroud)
所以你应该: