2015-01-07 16 views
5

私はCloudKitに写真をアップロードし、NSDataとしてそれを保存しようとしましたが、カメラで撮影した比較的大きな絵、と、私はこのエラーを取得:データの最大サイズはすることができますされCloudKitに大きな画像を保存するには?

Error saving record <CKRecordID: 0x15998770; 04359DFA-8370-4000-9F53-5694FC53FA9C:(_defaultZone:__defaultOwner__)> to server: record too large id=04359DFA-8370-4000-9F53-5694FC53FA9C of type UserSetting 

CloudKitに保存しますか?

カメラで撮影した大きな画像をどのように保存するのですか?CloudKit

2枚の画像を試してみましたが、そのサイズをプロットしました。

let d = UIImagePNGRepresentation(image) 
println("d.length: \(d.length)") 
  • d.length: 55482 <は -
  • d.length: 17614327 <に動作します -

答えて

8

を動作しません。あなたはCKAssetとして画像を保存する必要があります。 CKRecordにはサイズ制限があります。 CKAssetの場合、CloudKitストレージの制限の横にはありません。ドキュメントによると:[アップル](https://developer.apple.com/library/prerelease/ios/documentation/CloudKitから

var File : CKAsset = CKAsset(fileURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("image-not-available", ofType: "jpg")!)) 
+2

Use assets for discrete data files. When you want to associate images or other discrete files with a record, use a CKAsset object to do so. The total size of a record’s data is limited to 1 MB though assets do not count against that limit.

あなたはこのようCKAssetを作成することができます/Reference/CKAsset_class/index.html):*資産オブジェクトを使用して保存するファイルまたはデータは、250 MB以下である必要があります。* – Mojo66

+0

イメージからURLを作成する方法はありますか?私は、ユーザーがアプリ内の画像をクリックするか、UIImagePickerControllerを使用するかを選択します。 – penatheboss

関連する問題