damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 74dbbcf1a21609c6514528d36604f087f3639673
parent e3283fc8f84b25ef2a7889678c501106eb3c9592
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 27 Mar 2023 11:55:59 -0400

Fix image uploading

Diffstat:
Mdamus/Models/ImageUploadModel.swift | 2+-
Mdamus/Views/AttachMediaUtility.swift | 5++---
2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/damus/Models/ImageUploadModel.swift b/damus/Models/ImageUploadModel.swift @@ -14,7 +14,7 @@ enum MediaUpload { case video(URL) var is_image: Bool { - guard case .image = self else { + if case .image = self { return true } diff --git a/damus/Views/AttachMediaUtility.swift b/damus/Views/AttachMediaUtility.swift @@ -30,7 +30,6 @@ fileprivate func create_upload_body(mediaData: Data, boundary: String, mediaUplo } func create_upload_request(mediaToUpload: MediaUpload, mediaUploader: MediaUploader, progress: URLSessionTaskDelegate) async -> ImageUploadResult { - var mediaIsImage: Bool = false var mediaData: Data? guard let url = URL(string: mediaUploader.postAPI) else { return .failed(nil) @@ -56,7 +55,7 @@ func create_upload_request(mediaToUpload: MediaUpload, mediaUploader: MediaUploa return .failed(nil) } - request.httpBody = create_upload_body(mediaData: mediaData, boundary: boundary, mediaUploader: mediaUploader, mediaIsImage: mediaIsImage) + request.httpBody = create_upload_body(mediaData: mediaData, boundary: boundary, mediaUploader: mediaUploader, mediaIsImage: mediaToUpload.is_image) do { let (data, _) = try await URLSession.shared.data(for: request, delegate: progress) @@ -66,7 +65,7 @@ func create_upload_request(mediaToUpload: MediaUpload, mediaUploader: MediaUploa return .failed(nil) } - guard let url = mediaUploader.getMediaURL(from: responseString, mediaIsImage: mediaIsImage) else { + guard let url = mediaUploader.getMediaURL(from: responseString, mediaIsImage: mediaToUpload.is_image) else { print("Upload failed getting media url") return .failed(nil) }