有没有方法可以获取尚未下载的原始文件的fileSize
属性? 我使用UIDocumentPickerViewController
获取了fileURL
,然后尝试检查fileSize
,但似乎它只是尚未下载的原始文件的别名,并且大小不正确。
debugPrint("size: ", try? fileURL.resourceValues(forKeys: [.fileSizeKey, .ubiquitousItemDownloadingStatusKey]))
"fileURL: " file:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/Downloads/.vvvvv.mp4.icloud
"size: " Optional(Foundation.URLResourceValues(_values: [__C.NSURLResourceKey(_rawValue: NSURLUbiquitousItemDownloadingStatusKey): NSURLUbiquitousItemDownloadingStatusNotDownloaded, __C.NSURLResourceKey(_rawValue: NSURLFileSizeKey): 340], _keys: Set([__C.NSURLResourceKey(_rawValue: NSURLUbiquitousItemDownloadingStatusKey), __C.NSURLResourceKey(_rawValue: NSURLFileSizeKey)])))