Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

iswiftshek
Copy link
Contributor

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


if assetPath != nil {
let ext = assetPath!.absoluteString?.components(separatedBy: "ext=")[1].lowercased()
if ext == "png" || ext == "jpg" || ext == "heic" {
Copy link
Member

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)
Copy link
Member

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"
Copy link
Member

@codedentwickler codedentwickler Dec 18, 2019

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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"
Copy link
Member

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

@cpg
Copy link
Member

cpg commented Jul 6, 2020

We close this one in favor of #301

@cpg cpg closed this Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants