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

Image uploading #652

Merged
merged 21 commits into from
Oct 1, 2023
Merged

Image uploading #652

merged 21 commits into from
Oct 1, 2023

Conversation

Sjmarf
Copy link
Contributor

@Sjmarf Sjmarf commented Sep 25, 2023

Lets you attach images to posts.


The animation for the image-picker sheet closing is broken on iOS 17, but works on previous iOS versions. This is just a visual bug though.

@Sjmarf Sjmarf requested a review from a team as a code owner September 25, 2023 19:56
@Sjmarf Sjmarf requested review from ShadowJonathan and EricBAndrews and removed request for a team September 25, 2023 19:56
Copy link
Collaborator

@mormaer mormaer left a comment

Choose a reason for hiding this comment

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

Based on the possible leaking of images I think we should address that in some respect as part of this PR?

Mlem/Views/Shared/Composer/PostDetailEditorView.swift Outdated Show resolved Hide resolved
@boscojwho
Copy link
Contributor

Does the app ask for iCloud Drive user permission on launch for this PR?

  • Wondering because I can't test on device right now, but it asked me when I ran it in simulator.

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 29, 2023

Does the app ask for iCloud Drive user permission on launch for this PR?

I didn't run into this. I'm using Apple's Photo picker, which supposedly handles all of the permissions stuff for us

@boscojwho
Copy link
Contributor

boscojwho commented Sep 29, 2023

Should we surface the failure reason to users?

  • I tried to upload twice in simulator, and both times it looked like it was going to finish, then just "Failed".
  • Debugged it and it was a timeout, even though the upload operation only took ~5 seconds?
  • Some possibly useful errors to surface
    i. timeout
    ii. file too big
    iii. instance doesn't support images (is this a thing?)
Uploading: 40.0%
Uploading: 42.0%
Uploading: 57.0%
Uploading: 60.0%
Uploading: 76.0%
Upload failed: Optional("Request error: error sending request for url (http://pictrs:8080/image): operation timed out")
Upload failed: Response is nil

@boscojwho
Copy link
Contributor

Does the app ask for iCloud Drive user permission on launch for this PR?

I didn't run into this. I'm using Apple's Photo picker, which supposedly handles all of the permissions stuff for us

Cool, ignore then, probably just a simulator/macOS thing.

Copy link
Collaborator

@mormaer mormaer left a comment

Choose a reason for hiding this comment

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

Couple of comments, if some will prove a pain we could address them in a follow up - I have a PR mostly ready for #651 which will require me to move things around a bit once this goes in as the session no longer holds on to a URL as it proved a headache to support dynamic resolution while the requests work that way... 😭 so perhaps addressing it as part of the other PR will make more sense and avoid blocking this any further...

one additional question, do we catch and remove an uploaded file if the user cancels the post without submitting, or only if they cancel the image directly?

Mlem/API/APIClient/APIClient+Pictrs.swift Outdated Show resolved Hide resolved
Mlem/API/APIClient/APIClient+Pictrs.swift Show resolved Hide resolved
Mlem/API/APIClient/APIClient+Pictrs.swift Outdated Show resolved Hide resolved
Mlem/Repositories/PictrsRespository.swift Show resolved Hide resolved
Mlem/Views/Shared/Components/ImageUploadView.swift Outdated Show resolved Hide resolved
Mlem/Views/Shared/Composer/PostDetailEditorView.swift Outdated Show resolved Hide resolved
@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 29, 2023

one additional question, do we catch and remove an uploaded file if the user cancels the post without submitting, or only if they cancel the image directly?

No, we don't - I'd forgotten about that case. I'll add that in tomorrow 👍

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 29, 2023

  • Debugged it and it was a timeout, even though the upload operation only took ~5 seconds?

I had this issue with test-mlem, but it was working fine on other instances.

@Sjmarf
Copy link
Contributor Author

Sjmarf commented Sep 29, 2023

i. timeout

Sure, I'll add support for this.

ii. file too big

Done this already

iii. instance doesn't support images (is this a thing?)

Perhaps. I'll find out

Copy link
Collaborator

@mormaer mormaer left a comment

Choose a reason for hiding this comment

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

🖼️ -> 🚀

I reckon we're doing everything we can to make the user aware / proactively removing the images if they don't post etc 👍

@Sjmarf Sjmarf merged commit c4c42c5 into dev Oct 1, 2023
4 checks passed
@Sjmarf Sjmarf deleted the sjmarf/image-upload branch October 1, 2023 12:52
boscojwho added a commit that referenced this pull request Oct 11, 2023
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.

Implement uploading API Upload media
4 participants