Skip to content
Snippets Groups Projects
Commit cf51ed3a authored by Aylin's avatar Aylin
Browse files

file previews work again!

parent 0fbcbef2
Branches
No related tags found
1 merge request!83Resolve "Integrate attachment functionality in new ComposeView"
......@@ -22,6 +22,21 @@ struct Attachment: DisplayAttachment, Equatable {
myID = UUID()
}
/// download calling attachment into the documents diectory
func download(){
func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return paths[0]
}
let filename = getDocumentsDirectory().appendingPathComponent(self.myName)
do {
try self.myData.write(to: filename)
} catch let error as NSError {
print("Error: \(error)")
}
}
/// a func that returns the size of the calling attachment file as a string
func countData() -> String {
// size in byte
......
......@@ -113,6 +113,10 @@ struct AddAttachmentsView: View {
// create Attachment and add in to the attachments list
let newAttachment = Attachment(fileName: fileName, fileData: fileData)
model.attachments.append(newAttachment)
// download the file into the documents directory
// this is necessary, because the QuickLookView later uses that data
// to create a preview
newAttachment.download()
} catch {
// Error while loading file
print("Error while importing file.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment