CKAsset in server record contains no fileURL, cannot even check for nil

ckasset fileurl
swift ckrecord
cloudkit cloud functions
save image to cloudkit swift
ckrecord data types
cloudkit create record
cloudkit multiple devices
save data to cloudkit

I am testing a sync conflict when I save a record that contains a CKAsset (simply a JPG image) using CKModifyRecordsOperation with a save policy of .IfServerRecordUnchanged. I am getting the error CKErrorCode.ServerRecordChanged. This CKError returns me useful information for conflict resolution, including the CKRecord I tried to save, and the current server version of the record. The first is in error.userInfo[CKRecordChangedErrorClientRecordKey] the second is in error.userInfo[CKRecordChangedErrorServerRecordKey].

My problem is I am trying to access the server record's CKAsset with this code:

if let photoAsset = rec["myPhoto"] as? CKAsset {
  print("PhotoAsset.fileURL: \(photoAsset.fileURL)")  // BAD_ACCESS ERROR HERE = NSData(contentsOfURL: photoAsset.fileURL)

I don't get how this is possible. But after further investigating, I print out the client and server CKRecords and the server one is missing the 'path' property.

client CKAsset...myPhoto (modified) -> CKAsset: 0x7b960d90; path=~/tmp/BF185B2C-7A39-4730-9530-9797E843243Aphoto, size=373959, uploadRank=0, uploadReceipt=A92Eg1qoyPG7yrg3, UUID=3C2D5DC8-4FF5-4A81-853B-395FC1C59862, referenceSignature=<012fd149 200fc600 617e3907 88763e3e 5002abbf 5b>, flags=uploaded, wrappedEncryptionKey=, signature=<0134a297 38d52f5f 9275bfba fce5b1a8 3d6b9692 d3>

server CKAsset...myPhoto = CKAsset: 0x7be700d0; referenceSignature=<015337bd 84409893 7c014f46 36248d27 ce911dc3 7a>, size=373959, uploadRank=0, UUID=DF5D2EB4-033C-49A2-AF52-6055B5A44106, wrappedEncryptionKey=<767e7cfd d1e62110 32119ee9 f6f026b3 5bcf0cc3 8053a4de>, signature=<0134a297 38d52f5f 9275bfba fce5b1a8 3d6b9692 d3>

Notice how path=~/tmp/C706423B-A3E8-4051-A9B3-483C718BFBF5photo is missing from the server one? Can anyone explain this? To fix it I try to avoid touching the CKAsset from the server record. I would like to at least be able to check for nil. I wanted to put this out there in case it helps anyone else.

Due to the crash on accessing fileURL, this is most likely a framework bug. Probably an oversight on account of the CKRecord being buried in a dictionary. I just follow it up with a regular fetch(withRecordID:).

Newest 'ckasset' Questions, CKAsset in server record contains no fileURL, cannot even check for nil. I am testing a sync conflict when I save a record that contains a CKAsset (simply a JPG� By default, the volume is formatted to use small-size file records. After data deduplication is performed on a volume for the first time, you should perform a full backup immediately afterward. Perform garbage-collection jobs weekly on the chunk store to remove chunks that are no longer used.

I'm experiencing this issue as well on iOS 11.2.1 when accessing CKAsset from serverRecord property in CKRecord. It's a little bit frustrating. A workaround is fetching the object once again via func fetch(withRecordID... and then access fileURL.

swift, CKAsset in server record contains no fileURL, cannot even check for nil. 发表于 2016-12-10 05:29:56. 活跃于 2018-01-02 15:34:07. 查看149 次. swift cloudkit� // // For client requests, a nil body means the request has no // body, such as a GET request. The HTTP Client's Transport // is responsible for calling the Close method. // // For server requests, the Request Body is always non-nil // but will return EOF immediately when no body is present. // The Server will close the request body.

This seems like the correct behavior, not a bug.

CloudKit informed you that your write operation failed because you weren't working from the latest CKRecord and gave you a non-hydrated version of the server's current CKRecord so you could determine which fields were different from your starting point. The rest is up to you.

If CloudKit returned the fully hydrated server record in the error response for a write operation, it would potentially waste enormous amounts of bandwidth/resources.

That is why CKAssets exist: to separate the size-constrained key-value fields associated with a CKRecord from the unlimited-size binary assets that can be attached to them.

CKAsset, class CKAsset : NSObject When you save a record that has an asset, CloudKit saves both the record and CloudKit saves only the asset data; it does not save the filename or any other an asset, you can retrieve the asset data with the URL in the fileURL property. You cannot delete asset data directly from the server. Describes how to use the System File Checker tool to troubleshoot missing or corrupted system files in Windows 8.1, Windows 8, Windows 7 or Windows Vista.

CKAsset not Saved to CloudKit - 绵阳斯懿新材料科技有限公司, user3069232 should get credit for the answer. The code above does save the record to CloudKit before the image file save has completed. Hi @Raj B,. I'd certainly recommend you to use multiple successive MergeContent processors instead of one. If your trigger is the size: you want to end with a file of 100MB, then I'd use a first MergeContent to merge small files into files of 10MB and then another one to merge into one file of 100MB.

CKAsset in CloudKit - 绵阳斯懿新材料科技有限公司, CKAsset in server record contains no fileURL, cannot even check for nil. I am testing a sync conflict when I save a record that contains a CKAsset (simply a JPG� Well my Linux box has no mouse/keyboard/screen, I can only access it over Telnet. If I can figure out how to share my Windows drive so the Linux box can access it then I'll give it a go but it's not really an ideal solution as I really want just be be able to drag and drop my files really.

CloudKit 101, Even though CloudKit is widely used by Apple in first-party apps and by It's true that Apple has had issues before when it comes to cloud You as the developer can't access data in a user's private database. Now, to change the values in records, the code will look a lot cleaner (and be a lot safer): If some Windows functions aren't working or Windows crashes, use the System File Checker to scan Windows and restore your files. Though the steps below might look complicated at first glance, just follow them in order, step-by-step, and we’ll try to get you back on track.

  • Any luck with finding an explanation for this issue? I have the same problem but only for iOS 9, on iOS 10 it works for me. Syncing assets over CloudKit crashes on all iOS 9 devices. FYI: I'm using Swift 3.0.
  • I have the same issue. CKAsset.fileUrl is nil, when opening server record. iOS12.1.2, Xcode 10.2.1.