Browse Source

Fix setting ScanDocument filesize

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 years ago
parent
commit
fd1390a72f
1 changed files with 5 additions and 3 deletions
  1. 5 3
      iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

+ 5 - 3
iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift

@@ -459,6 +459,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
             return
         }
+        let fileUrl = URL(fileURLWithPath: fileNameGenerateExport)
 
         // Text Recognition TXT
         if fileType == "TXT" && self.form.formRow(withTag: "textRecognition")!.value as! Int == 1 {
@@ -489,7 +490,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             }
 
             do {
-                try textFile.write(to: NSURL(fileURLWithPath: fileNameGenerateExport) as URL, atomically: true, encoding: .utf8)
+                try textFile.write(to: fileUrl, atomically: true, encoding: .utf8)
             } catch {
                 NCUtility.shared.stopActivityIndicator()
                 NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
@@ -562,7 +563,7 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             UIGraphicsEndPDFContext()
 
             do {
-                try pdfData.write(toFile: fileNameGenerateExport, options: .atomic)
+                try pdfData.write(to: fileUrl, options: .atomic)
             } catch {
                 print("error catched")
             }
@@ -579,13 +580,14 @@ class NCCreateFormUploadScanDocument: XLFormViewController, NCSelectDelegate, NC
             }
 
             do {
-                try data.write(to: NSURL.fileURL(withPath: fileNameGenerateExport), options: .atomic)
+                try data.write(to: fileUrl, options: .atomic)
             } catch {
                 NCUtility.shared.stopActivityIndicator()
                 NCContentPresenter.shared.messageNotification("_error_", description: "_error_creation_file_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCreationFile)
                 return
             }
         }
+        metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: fileNameGenerateExport)
 
         NCUtility.shared.stopActivityIndicator()