diff --git a/Tests/NextcloudUnitTests/AssetUploadTest.swift b/Tests/NextcloudUnitTests/AssetUploadTest.swift new file mode 100644 index 0000000000..72f541042b --- /dev/null +++ b/Tests/NextcloudUnitTests/AssetUploadTest.swift @@ -0,0 +1,36 @@ +// +// AssetUploadTest.swift +// NextcloudTests +// +// Created by A200020526 on 12/06/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +import XCTest + +final class AssetUploadTest: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/iOSClient/Main/Create cloud/NCUploadAssets.swift b/iOSClient/Main/Create cloud/NCUploadAssets.swift index c734d05a49..2ad771c0c3 100644 --- a/iOSClient/Main/Create cloud/NCUploadAssets.swift +++ b/iOSClient/Main/Create cloud/NCUploadAssets.swift @@ -181,6 +181,7 @@ struct UploadAssetsView: View { } private func setFileNameMaskForPreview(fileName: String?) -> String { + let utilityFileSystem = NCUtilityFileSystem() guard let asset = uploadAssets.assets.first?.phAsset else { return "" } var preview: String = "" let creationDate = asset.creationDate ?? Date() @@ -200,8 +201,30 @@ struct UploadAssetsView: View { ) let trimmedPreview = preview.trimmingCharacters(in: .whitespacesAndNewlines) + + if !(fileName?.isEmpty ?? false) { + + NCKeychain().setFileNameMask(key: fileName ?? "", mask: NCGlobal.shared.keyFileNameMask) + preview = CCUtility.createFileName(asset.value(forKey: "filename") as? String, + fileDate: creationDate, fileType: asset.mediaType, + keyFileName: NCGlobal.shared.keyFileNameMask, + keyFileNameType: NCGlobal.shared.keyFileNameType, + keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, + forcedNewFileName: false) + + } else { + + NCKeychain().setFileNameMask(key: "", mask: NCGlobal.shared.keyFileNameMask) + preview = CCUtility.createFileName(asset.value(forKey: "filename") as? String, + fileDate: creationDate, + fileType: asset.mediaType, + keyFileName: nil, + keyFileNameType: NCGlobal.shared.keyFileNameType, + keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, + forcedNewFileName: false) + } - return String(format: NSLocalizedString("_preview_filename_", comment: ""), "MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm") + ":" + "\n\n" + (trimmedPreview as NSString).deletingPathExtension + return (!isMaintainOriginalFilename ? (String(format: NSLocalizedString("_preview_filename_", comment: ""), "MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm") + ":" + "\n\n") : #"\#(NSLocalizedString("_filename_", comment: "") ): "#) + preview } private func save(completion: @escaping (_ metadatasNOConflict: [tableMetadata], _ metadatasUploadInConflict: [tableMetadata]) -> Void) { @@ -339,74 +362,48 @@ struct UploadAssetsView: View { NavigationView { ZStack(alignment: .top) { List { - Section(footer: Text(NSLocalizedString("_modify_image_desc_", comment: ""))) { - ScrollView(.horizontal) { - LazyHGrid(rows: gridItems, alignment: .center, spacing: 10) { - ForEach(0..