Skip to content

Conversation

@iswiftshek
Copy link
Contributor

Added the upload feature. The user can either take a new photo with camera or upload from the gallery.

a

Copy link
Member

@csoni111 csoni111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine with images from the Library but couldn't test with images directly from Camera.

else {
url = ServerApi.shared!.getShareUri(share)!.absoluteString
}
Network.shared.uploadFile(url, data: image.jpegData(compressionQuality: 100)!, fileName: "IMG.jpeg") { success in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the static name IMG.jpeg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used static name IMG.jpeg so that we would get file names as IMG.jpeg, IMG_xyz.jpeg (where xyz is a number, this when IMG already exists), IMG_abc.jpeg etc.
I couldn't get the name of the selected file, from the file I get something in the format "some_number.jpeg", which is not the file name.
Or should I pass that "some_number.jpeg" in place of 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.

What exactly is xyz or abc ??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He means on the first upload the filename will be like IMG.jpeg then after that, it will be IMG_yyyymmdd-HHMM.jpeg format. This file renaming is handled by our fs when it gets a file with the same name already present in the directory but different md5 hash. Here yyyymmdd-HHMM is what he was referring to as xyz or abc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iswiftshek ideally the file name should be kept the same as it was on user's iPhone. Is there no way to get the original filename on the device?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that should be done. But the last time I looked into this, I couldn't find a way around it. But to the best of what I remember there was one method but it was deprecated.
I'll look into it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a way to get the file name for images and videos picked from UIPickerViewController.
However, in case of documents, we get the file name directly from the url.

@csoni111 csoni111 changed the base branch from beta to feature/upload August 24, 2019 11:15
@iswiftshek iswiftshek mentioned this pull request Aug 25, 2019
@iswiftshek iswiftshek closed this Aug 25, 2019
@iswiftshek iswiftshek deleted the upload-feature branch August 25, 2019 03:06
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.

3 participants