|
@@ -43,24 +43,23 @@ extension FileProviderExtension {
|
|
|
if (metadata.hasPreview) {
|
|
|
|
|
|
let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, activeUrl: fileProviderData.sharedInstance.accountUrl)!
|
|
|
- let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
|
|
|
+ //let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
|
|
|
let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
|
|
|
|
|
|
- NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNamePreviewLocalPath: fileNamePreviewLocalPath , widthPreview: Int(k_sizePreview), heightPreview: Int(k_sizePreview), fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: Int(k_sizeIcon)) { (account, imagePreview, imageIcon, errorCode, errorDescription) in
|
|
|
- if errorCode == 0 && imageIcon != nil {
|
|
|
- if let data = imageIcon!.pngData() {
|
|
|
- perThumbnailCompletionHandler(itemIdentifier, data, nil)
|
|
|
- } else {
|
|
|
- perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
|
|
|
- }
|
|
|
+ NCCommunication.shared.getPreview(fileNamePath: fileNamePath, widthPreview: Int(k_sizeIcon), heightPreview: Int(k_sizeIcon)) { (account, data, errorCode, errorDescription) in
|
|
|
+ if errorCode == 0 && data != nil {
|
|
|
+ do {
|
|
|
+ try data!.write(to: URL.init(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
|
|
|
+ } catch { }
|
|
|
+ perThumbnailCompletionHandler(itemIdentifier, data, nil)
|
|
|
} else {
|
|
|
perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
|
|
|
}
|
|
|
-
|
|
|
counterProgress += 1
|
|
|
- if (counterProgress == progress.totalUnitCount) { completionHandler(nil) }
|
|
|
+ if (counterProgress == progress.totalUnitCount) {
|
|
|
+ completionHandler(nil)
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
|
|
|
counterProgress += 1
|