This repository has been archived by the owner on Apr 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished application document upload
- Loading branch information
1 parent
3bb3c16
commit bc54470
Showing
8 changed files
with
98 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+31.9 KB
...le.xcodeproj/project.xcworkspace/xcuserdata/cb.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// FileFormatter.swift | ||
// mobile | ||
// | ||
// Created by cb on 12.09.23. | ||
// | ||
|
||
import Foundation | ||
import UniformTypeIdentifiers | ||
|
||
struct FileFormatter { | ||
|
||
static func toUTType(allowedCvFormat: [String]) -> [UTType] { | ||
let recognizedFileExtensions: [String: UTType] = [ | ||
".pdf": .pdf, | ||
".xml": .xml, | ||
".txt": .plainText, | ||
".docx": UTType("org.openxmlformats.wordprocessingml.document")! | ||
] | ||
|
||
var allowedCvTypes: [UTType] = [] | ||
|
||
for fileExtension in allowedCvFormat { | ||
let lowercasedExtension = fileExtension.lowercased() | ||
|
||
if let utType = recognizedFileExtensions[lowercasedExtension] { | ||
allowedCvTypes.append(utType) | ||
} else { | ||
// Handle custom or unsupported file extensions here | ||
print("Custom or unsupported file extension: \(fileExtension)") | ||
// Instead of fatalError, you can choose to handle it differently | ||
} | ||
} | ||
print("STRINGTypes: \(allowedCvFormat)") | ||
print("UTTypes: \(allowedCvTypes)") | ||
return allowedCvTypes | ||
} | ||
|
||
func handleDocumentSelection(fileName: String, result: Result<URL, Error>, completion: @escaping (Result<String, APIError>) -> Void) { | ||
switch result { | ||
case .success(let selectedURL): | ||
return completion(.success(selectedURL.lastPathComponent)) | ||
|
||
case .failure(let error): | ||
print("File Selection Error: \(error.localizedDescription)") | ||
return completion(.failure(APIError.fileFormatError(error.localizedDescription))) | ||
} | ||
} | ||
} |