Jelajahi Sumber

Merge pull request #2170 from nextcloud/preview

Preview
Marino Faggiana 2 tahun lalu
induk
melakukan
200f8ae774

+ 2 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -358,7 +358,6 @@
 		F78F74342163757000C2ADAD /* NCTrash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F78F74332163757000C2ADAD /* NCTrash.storyboard */; };
 		F78F74362163781100C2ADAD /* NCTrash.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78F74352163781100C2ADAD /* NCTrash.swift */; };
 		F790110E21415BF600D7B136 /* NCViewerRichdocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */; };
-		F793E59B28B75FB0005E4B02 /* NCAutoUpload.swift in Sources */ = {isa = PBXBuildFile; fileRef = F72CD63925C19EBF00F46F9A /* NCAutoUpload.swift */; };
 		F793E59D28B761E7005E4B02 /* NCNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75A9EE523796C6F0044CFCE /* NCNetworking.swift */; };
 		F793E59E28B763C2005E4B02 /* NCAskAuthorization.swift in Sources */ = {isa = PBXBuildFile; fileRef = F733598025C1C188002ABA72 /* NCAskAuthorization.swift */; };
 		F793E59F28B764F6005E4B02 /* NCContentPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F765608E23BF813500765969 /* NCContentPresenter.swift */; };
@@ -2743,7 +2742,6 @@
 				F77ED59328C9CEA000E24ED0 /* ToolbarWidgetProvider.swift in Sources */,
 				F72A17D828B221E300F3F159 /* DashboardWidgetView.swift in Sources */,
 				F77ED59528C9CEA400E24ED0 /* ToolbarWidgetView.swift in Sources */,
-				F793E59B28B75FB0005E4B02 /* NCAutoUpload.swift in Sources */,
 				F78302FB28B4C3EE00B84583 /* NCManageDatabase+Video.swift in Sources */,
 				F72EA95228B7BA2A00C88F0C /* DashboardWidgetProvider.swift in Sources */,
 				F793E5A228B76580005E4B02 /* NCNetworkingChunkedUpload.swift in Sources */,
@@ -3405,7 +3403,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 9;
+				CURRENT_PROJECT_VERSION = 10;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;
@@ -3467,7 +3465,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 9;
+				CURRENT_PROJECT_VERSION = 10;
 				DEVELOPMENT_TEAM = NKUJUXUJ3B;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
 				ENABLE_TESTABILITY = YES;

+ 54 - 37
Widget/Files/FilesData.swift

@@ -95,7 +95,7 @@ func getFilesDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escapi
         return completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "xmark.icloud", footerText: NSLocalizedString("_no_active_account_", value: "No account found", comment: "")))
     }
 
-    func isLive(file: NKFile, files: [NKFile]) -> Bool {
+    @Sendable func isLive(file: NKFile, files: [NKFile]) -> Bool {
 
         if file.ext.lowercased() != "mov" { return false }
         if files.filter({ ($0.fileNameWithoutExt == file.fileNameWithoutExt) && ($0.ext.lowercased() == "jpg") }).first != nil {
@@ -201,46 +201,63 @@ func getFilesDataEntry(isPreview: Bool, displaySize: CGSize, completion: @escapi
     
     let options = NKRequestOptions(timeout: 15)
     NextcloudKit.shared.searchBodyRequest(serverUrl: account.urlBase, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles(), options: options) { _, files, data, error in
+        Task {
+            var datas: [FilesData] = []
+            var imageRecent = UIImage(named: "file")!
 
-        var datas: [FilesData] = []
-        
-        for file in files {
-            guard !file.directory else { continue }
-            guard !isLive(file: file, files: files) else { continue }
-            let subTitle = CCUtility.dateDiff(file.date as Date) + " · " + CCUtility.transformedSize(file.size)
-            // url: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
-            guard var path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
-            if path.first == "/" { path = String(path.dropFirst())}
-            guard let user = file.user.urlEncoded else { continue }
-            let link = file.urlBase + "/f/" + file.fileId
-            let urlString = "nextcloud://open-file?path=\(path)&user=\(user)&link=\(link)"
-            guard let url = URL(string: urlString) else { continue }
-            // Build Recent Data
-            var imageRecent = UIImage()
-            if let image = NCUtility.shared.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, status: 0, createPreviewMedia: false) {
-                imageRecent = image
-            } else if !file.iconName.isEmpty {
-                imageRecent = UIImage(named: file.iconName)!
-            } else {
-                imageRecent = UIImage(named: "file")!
+            for file in files {
+                guard !file.directory else { continue }
+                guard !isLive(file: file, files: files) else { continue }
+
+                // SUBTITLE
+                let subTitle = CCUtility.dateDiff(file.date as Date) + " · " + CCUtility.transformedSize(file.size)
+
+                // URL: nextcloud://open-file?path=Talk/IMG_0000123.jpg&user=marinofaggiana&link=https://cloud.nextcloud.com/f/123
+                guard var path = NCUtilityFileSystem.shared.getPath(path: file.path, user: file.user, fileName: file.fileName).urlEncoded else { continue }
+                if path.first == "/" { path = String(path.dropFirst())}
+                guard let user = file.user.urlEncoded else { continue }
+                let link = file.urlBase + "/f/" + file.fileId
+                let urlString = "nextcloud://open-file?path=\(path)&user=\(user)&link=\(link)"
+                guard let url = URL(string: urlString) else { continue }
+
+                // IMAGE
+                if !file.iconName.isEmpty {
+                    imageRecent = UIImage(named: file.iconName)!
+                }
+                if let image = NCUtility.shared.createFilePreviewImage(ocId: file.ocId, etag: file.etag, fileNameView: file.fileName, classFile: file.classFile, status: 0, createPreviewMedia: false) {
+                    imageRecent = image
+                } else if file.hasPreview {
+                    do {
+                        let fileNamePathOrFileId = CCUtility.returnFileNamePath(fromFileName: file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, account: account.account)!
+                        let fileNamePreviewLocalPath = CCUtility.getDirectoryProviderStoragePreviewOcId(file.ocId, etag: file.etag)!
+                        let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(file.ocId, etag: file.etag)!
+                        let (_, _, imageIcon, _, _) = try await NextcloudKit.shared.downloadPreview(fileNamePathOrFileId: fileNamePathOrFileId, fileNamePreviewLocalPath: fileNamePreviewLocalPath, widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon)
+                        if let image = imageIcon {
+                            imageRecent = image
+                        }
+                    } catch {
+                        print(error)
+                    }
+                }
+
+                // DATA
+                let data = FilesData.init(id: file.ocId, image: imageRecent, title: file.fileName, subTitle: subTitle, url: url)
+                datas.append(data)
+                if datas.count == filesItems { break}
             }
-            let data = FilesData.init(id: file.ocId, image: imageRecent, title: file.fileName, subTitle: subTitle, url: url)
-            datas.append(data)
-            if datas.count == filesItems { break}
-        }
 
-        if error != .success {
-            completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
-        } else if datas.isEmpty {
-            var footerText = NSLocalizedString("_no_data_available_", comment: "")
-            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-            if serverVersionMajor < NCGlobal.shared.nextcloudVersion25 {
-                footerText = NSLocalizedString("_widget_available_nc25_", comment: "")
+            if error != .success {
+                completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "xmark.icloud", footerText: error.errorDescription))
+            } else if datas.isEmpty {
+                var footerText = NSLocalizedString("_no_data_available_", comment: "")
+                let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+                if serverVersionMajor < NCGlobal.shared.nextcloudVersion25 {
+                    footerText = NSLocalizedString("_widget_available_nc25_", comment: "")
+                }
+                completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "checkmark.icloud", footerText: footerText))
+            } else {
+                completion(FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, tile: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " files"))
             }
-            completion(FilesDataEntry(date: Date(), datas: datasPlaceholder, isPlaceholder: true, tile: title, footerImage: "checkmark.icloud", footerText: footerText))
-        } else {
-            completion(FilesDataEntry(date: Date(), datas: datas, isPlaceholder: false, tile: title, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " files"))
         }
     }
 }
-

+ 35 - 11
iOSClient/AppDelegate.swift

@@ -63,6 +63,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var errorITMS90076: Bool = false
 
     private var privacyProtectionWindow: UIWindow?
+    private var autoUploadInprogress: Bool = false
     
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 
@@ -242,8 +243,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         // Initialize Auto upload
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+        if !autoUploadInprogress {
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+                self.autoUploadInprogress = false
+            }
+        } else {
+            NKCommon.shared.writeLog("Auto upload already in progress.")
         }
 
         // Required unsubscribing / subscribing
@@ -327,8 +333,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCPushNotification.shared().pushNotification()
 
         // Start Auto Upload
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+        if !autoUploadInprogress {
+            autoUploadInprogress = true
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Initialize Auto upload with \(items) uploads")
+                self.autoUploadInprogress = false
+            }
+        } else {
+            NKCommon.shared.writeLog("Auto upload already in progress.")
         }
 
         // Start services
@@ -392,9 +404,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         NKCommon.shared.writeLog("Start handler refresh task [Auto upload]")
 
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
-            task.setTaskCompleted(success: true)
+        if !autoUploadInprogress {
+            autoUploadInprogress = true
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Completition handler refresh task [Auto upload] with \(items) uploads")
+                self.autoUploadInprogress = false
+                task.setTaskCompleted(success: true)
+            }
+        } else {
+            NKCommon.shared.writeLog("Auto upload already in progress.")
         }
     }
 
@@ -407,10 +425,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
 
         NKCommon.shared.writeLog("Start handler processing task [Auto upload]")
-        
-        NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
-            NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads")
-            task.setTaskCompleted(success: true)
+
+        if !autoUploadInprogress {
+            autoUploadInprogress = true
+            NCAutoUpload.shared.initAutoUpload(viewController: nil) { items in
+                NKCommon.shared.writeLog("Completition handler procesing task [Auto upload] with \(items) uploads")
+                self.autoUploadInprogress = false
+                task.setTaskCompleted(success: true)
+            }
+        } else {
+            NKCommon.shared.writeLog("Auto upload already in progress.")
         }
     }
 

+ 4 - 8
iOSClient/Data/NCManageDatabase.swift

@@ -1450,17 +1450,13 @@ class NCManageDatabase: NSObject {
         let realm = try! Realm()
 
         let sortProperties = [SortDescriptor(keyPath: "shareType", ascending: false), SortDescriptor(keyPath: "idShare", ascending: false)]
-
         let firstShareLink = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND shareType == 3", metadata.account, metadata.serverUrl, metadata.fileName).first
 
-        if firstShareLink == nil {
-
-            let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, metadata.fileName).sorted(by: sortProperties)
-            return(firstShareLink: firstShareLink, share: Array(results.map { tableShare.init(value: $0) }))
-
+        if let firstShareLink = firstShareLink {
+            let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND idShare != %d", metadata.account, metadata.serverUrl, metadata.fileName, firstShareLink.idShare).sorted(by: sortProperties)
+            return(firstShareLink: tableShare.init(value: firstShareLink), share: Array(results.map { tableShare.init(value: $0) }))
         } else {
-
-            let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@ AND idShare != %d", metadata.account, metadata.serverUrl, metadata.fileName, firstShareLink!.idShare).sorted(by: sortProperties)
+            let results = realm.objects(tableShare.self).filter("account == %@ AND serverUrl == %@ AND fileName == %@", metadata.account, metadata.serverUrl, metadata.fileName).sorted(by: sortProperties)
             return(firstShareLink: firstShareLink, share: Array(results.map { tableShare.init(value: $0) }))
         }
     }

+ 2 - 0
iOSClient/Main/NCFunctionCenter.swift

@@ -462,6 +462,8 @@ import Photos
 
     func openFileViewInFolder(serverUrl: String, fileNameBlink: String?) {
 
+        appDelegate.isSearchingMode = false
+        
         DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
             var topNavigationController: UINavigationController?
             var pushServerUrl = NCUtilityFileSystem.shared.getHomeServer(account: self.appDelegate.account)

+ 3 - 3
iOSClient/Media/Cell/NCGridMediaCell.swift

@@ -59,12 +59,12 @@ class NCGridMediaCell: UICollectionViewCell, NCCellProtocol {
     }
 
     func initCell() {
-        imageItem.backgroundColor = UIColor.lightGray
+        imageItem.backgroundColor = .secondarySystemBackground
         imageStatus.image = nil
         imageItem.image = nil
         imageItem.layer.masksToBounds = true
-        imageItem.layer.cornerRadius = 6
-        imageVisualEffect.layer.cornerRadius = 6
+        imageItem.layer.cornerRadius = 3
+        imageVisualEffect.layer.cornerRadius = 3
         imageVisualEffect.clipsToBounds = true
     }
 

+ 1 - 1
iOSClient/Media/NCMedia.swift

@@ -781,7 +781,7 @@ class NCMediaCommandView: UIView {
 
 class NCGridMediaLayout: UICollectionViewFlowLayout {
 
-    var marginLeftRight: CGFloat = 6
+    var marginLeftRight: CGFloat = 2
     var itemForLine: CGFloat = 3
 
     override init() {

+ 0 - 16
iOSClient/Networking/NCAutoUpload.swift

@@ -86,19 +86,11 @@ class NCAutoUpload: NSObject {
 
             self.getCameraRollAssets(viewController: viewController, account: account, selector: selector, alignPhotoLibrary: false) { assets in
                 guard let assets = assets, !assets.isEmpty else {
-                    #if EXTENSION_WIDGET
-                    NKCommon.shared.writeLog("Automatic upload widget, no new assets found [" + log + "]")
-                    #else
                     NKCommon.shared.writeLog("Automatic upload, no new assets found [" + log + "]")
-                    #endif
                     completion(0)
                     return
                 }
-                #if EXTENSION_WIDGET
-                NKCommon.shared.writeLog("Automatic upload widget, new \(assets.count) assets found [" + log + "]")
-                #else
                 NKCommon.shared.writeLog("Automatic upload, new \(assets.count) assets found [" + log + "]")
-                #endif
                 // Create the folder for auto upload & if request the subfolders
                 if !NCNetworking.shared.createFolder(assets: assets, selector: selector, useSubFolder: account.autoUploadCreateSubfolder, account: account.account, urlBase: account.urlBase) {
                     #if !EXTENSION
@@ -172,11 +164,7 @@ class NCAutoUpload: NSObject {
                             metadata.classFile = NKCommon.typeClassFile.image.rawValue
                         }
                         if selector == NCGlobal.shared.selectorUploadAutoUpload {
-                            #if EXTENSION_WIDGET
-                            NKCommon.shared.writeLog("Automatic upload widget added \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier)")
-                            #else
                             NKCommon.shared.writeLog("Automatic upload added \(metadata.fileNameView) with Identifier \(metadata.assetLocalIdentifier)")
-                            #endif
                             NCManageDatabase.shared.addPhotoLibrary([asset], account: account.account)
                         }
                         metadatas.append(metadata)
@@ -271,11 +259,7 @@ class NCAutoUpload: NSObject {
             guard let assets = assets else { return }
 
             NCManageDatabase.shared.addPhotoLibrary(assets, account: activeAccount.account)
-            #if EXTENSION_WIDGET
-            NKCommon.shared.writeLog("Widget align Photo Library \(assets.count)")
-            #else
             NKCommon.shared.writeLog("Align Photo Library \(assets.count)")
-            #endif
         }
     }
 

+ 120 - 3
iOSClient/Networking/NCNetworking.swift

@@ -299,6 +299,26 @@ import Photos
         }
     }
 
+    func isInTaskUploadBackground(fileName: String, completion: @escaping (_ exists: Bool) -> Void) {
+
+        let sessions: [URLSession] = [NCNetworking.shared.sessionManagerBackground, NCNetworking.shared.sessionManagerBackgroundWWan]
+
+        for session in sessions {
+            session.getAllTasks(completionHandler: { tasks in
+                for task in tasks {
+                    let url = task.originalRequest?.url
+                    let urlFileName = url?.lastPathComponent
+                    if urlFileName == fileName {
+                        completion(true)
+                    }
+                }
+                if session == sessions.last {
+                    completion(false)
+                }
+            })
+        }
+    }
+
     // MARK: - Download
 
     @objc func cancelDownload(ocId: String, serverUrl: String, fileNameView: String) {
@@ -1407,12 +1427,108 @@ import Photos
 
     // MARK: - TEST API
 
-    func getPreview(url: URL, options: NKRequestOptions = NKRequestOptions()) async throws -> Data? {
+    /*
+    func blabla(serverUrl: String, userId: String, account: String) {
+
+        let requestBodyRecent =
+        """
+        <?xml version=\"1.0\"?>
+        <d:searchrequest xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\" xmlns:nc=\"http://nextcloud.org/ns\">
+        <d:basicsearch>
+            <d:select>
+                <d:prop>
+                    <d:displayname/>
+                    <d:getcontenttype/>
+                    <d:resourcetype/>
+                    <d:getcontentlength/>
+                    <d:getlastmodified/>
+                    <d:getetag/>
+                    <d:quota-used-bytes/>
+                    <d:quota-available-bytes/>
+                    <permissions xmlns=\"http://owncloud.org/ns\"/>
+                    <id xmlns=\"http://owncloud.org/ns\"/>
+                    <fileid xmlns=\"http://owncloud.org/ns\"/>
+                    <size xmlns=\"http://owncloud.org/ns\"/>
+                    <favorite xmlns=\"http://owncloud.org/ns\"/>
+                    <creation_time xmlns=\"http://nextcloud.org/ns\"/>
+                    <upload_time xmlns=\"http://nextcloud.org/ns\"/>
+                    <is-encrypted xmlns=\"http://nextcloud.org/ns\"/>
+                    <mount-type xmlns=\"http://nextcloud.org/ns\"/>
+                    <owner-id xmlns=\"http://owncloud.org/ns\"/>
+                    <owner-display-name xmlns=\"http://owncloud.org/ns\"/>
+                    <comments-unread xmlns=\"http://owncloud.org/ns\"/>
+                    <has-preview xmlns=\"http://nextcloud.org/ns\"/>
+                    <trashbin-filename xmlns=\"http://nextcloud.org/ns\"/>
+                    <trashbin-original-location xmlns=\"http://nextcloud.org/ns\"/>
+                    <trashbin-deletion-time xmlns=\"http://nextcloud.org/ns\"/>
+                </d:prop>
+            </d:select>
+        <d:from>
+            <d:scope>
+                <d:href>%@</d:href>
+                <d:depth>infinity</d:depth>
+            </d:scope>
+        </d:from>
+        <d:where>
+            <d:lt>
+                <d:prop>
+                    <d:getlastmodified/>
+                </d:prop>
+                <d:literal>%@</d:literal>
+            </d:lt>
+        </d:where>
+        <d:orderby>
+            <d:order>
+                <d:prop>
+                    <d:getlastmodified/>
+                </d:prop>
+                <d:descending/>
+            </d:order>
+        </d:orderby>
+        <d:limit>
+            <d:nresults>50</d:nresults>
+        </d:limit>
+        </d:basicsearch>
+        </d:searchrequest>
+        """
+
+        let dateFormatter = DateFormatter()
+        dateFormatter.locale = Locale(identifier: "en_US_POSIX")
+        dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
+        let lessDateString = dateFormatter.string(from: Date())
+        let requestBody = String(format: requestBodyRecent, "/files/" + userId, lessDateString)
+
+        NextcloudKit.shared.searchBodyRequest(serverUrl: serverUrl, requestBody: requestBody, showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, data, error in
+
+            Task {
+                for file in files {
+                    if file.hasPreview {
+                        let fileNamePath = CCUtility.returnFileNamePath(fromFileName: file.fileName, serverUrl: file.serverUrl, urlBase: file.urlBase, account: account)!
+                        do {
+                            let data = try await self.getPreview(fileNamePath: fileNamePath, urlBase: file.urlBase)
+                            print("AAA")
+                        } catch {
+                            print(error)
+                        }
+                    }
+                }
+                print("END")
+            }
+        }
+    }
+    func getPreview(fileNamePath: String, urlBase: String, options: NKRequestOptions = NKRequestOptions()) async throws -> Data? {
 
         try await withUnsafeThrowingContinuation { continuation in
-            
+
+            guard let fileNamePath = fileNamePath.urlEncoded else {
+                return
+            }
             let headers = NKCommon.shared.getStandardHeaders(options: options)
-            
+            let endpoint = "index.php/core/preview.png?file=\(fileNamePath)&x=512&y=512&a=1&mode=cover"
+            guard let url = NKCommon.shared.createStandardUrl(serverUrl: urlBase, endpoint: endpoint) else {
+                return
+            }
+
             AF.request(url, method: .get, parameters: nil, encoding: URLEncoding.default, headers: headers, interceptor: nil).validate(statusCode: 200..<300).response(queue: NKCommon.shared.backgroundQueue) { (response) in
                 debugPrint(response)
                 
@@ -1425,6 +1541,7 @@ import Photos
             }
         }
     }
+    */
 }
 
 extension Array where Element == URLQueryItem {