-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload Feature #244
Upload Feature #244
Conversation
|
||
if assetPath != nil { | ||
let ext = assetPath!.absoluteString?.components(separatedBy: "ext=")[1].lowercased() | ||
if ext == "png" || ext == "jpg" || ext == "heic" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should be in the presenter though. That way our VCs stay lean.
} | ||
do { | ||
let data = try Data(contentsOf: videoURL as URL, options: .mappedIfSafe) | ||
print(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use the logger class.
do { | ||
let data = try Data(contentsOf: videoURL as URL, options: .mappedIfSafe) | ||
print(data) | ||
fileName = "VIDEO.mp4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a good way to name a file to be uploaded. The file name should be as unique as possible unless the backend handles that for you else there will be collision issues later.
You can use the timestamp or some other dynamic properties to make it unique.
self.presenter.getFiles(self.share, directory: self.directory) | ||
} | ||
} catch { | ||
print(error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use logger class.
switch encodingResult { | ||
case .success(let upload, _, _): | ||
upload.response { response in | ||
debugPrint(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
completion(true) | ||
} | ||
case .failure(let encodingError): | ||
print(encodingError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
guard let image = info[.editedImage] as? UIImage else { | ||
return | ||
} | ||
fileName = "IMG.jpeg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as "VIDEO.mp4"
below
We close this one in favor of #301 |
This PR completes the upload feature #239.
The user can now add images, videos and documents. (#233)
For images and videos, I used
IMAGE.jpeg
,VIDEO.mp4
and if those files already exist, they are uploaded in this format<TYPE>_yyyymmdd-HHMM.jpeg
Documents are uploaded with their original names as on the device like
fileDocument.pdf