damus
damus copied to clipboard
New feature: Image uploading/hosting
Hi all,
I've developed a feature for users to add images to their posts in-app. It works by sending the chosen image to an image host API (right now nostrimg.com is the only option) and appending the returned image URL to the end of the post.
It is flexible so that new APIs can easily be added simply by filling in some settings and implementing the uploadImage() function for the API. All of the API code can be found in Models/ImageHost.swift.
Also included in the PR is the ability for users to set a default image host in the config view.
I have also written an ImagePicker view which can be reused for other purposes in the app such as setting profile pic.
I had a hard time getting the layout to work well for the ReplyView, so for I've only enabled image uploading when creating top-level posts, but this can easily be changed by removing a couple lines of code.
Supports every image format I tested, including gifs. (It seems like the PHPickerViewController just converts still images to JPEG. It did that for webp, heif, png, etc.)
Other hosts worth looking into: nostr.build, imgur
Apologies if I did anything horribly wrong, I'm very new to iOS dev 😝
Nice :-) I like the idea of multiple options being available.
if I were to add something like this it would have to have a proper spec so that you can add/remove hosts without having anything hardcoded.
Tricky as all hosts would have bespoke API. Bitcoin Jungle looked at an interesting solution using Torrent.
if I were to add something like this it would have to have a proper spec so that you can add/remove hosts without having anything hardcoded.
As in, Damus calls APIs in one specific way, and it’s up to the hosts to adhere to that protocol?
Tricky as all hosts would have bespoke API. Bitcoin Jungle looked at an interesting solution using Torrent.
That's a really cool idea. But it seems like it would make it hard to remove illegal content ?
Wondering about standardizing on S3 compatible APIs?
Users can use tons of services that conform to this standard now, and nostr specific services could expose a compatible endpoint.
Users would set their endpoint and keys in settings on the client.
Clients could use signed URLs to upload directly.
Wondering about standardizing on S3 compatible APIs?
Users can use tons of services that conform to this standard now, and nostr specific services could expose a compatible endpoint.
Users would set their endpoint and keys in settings on the client.
Clients could use signed URLs to upload directly.
I thought S3 was very Amazon specific?
But yes, users setting API settings sounds the trick. What was that torrent based solution you sent me?
Wondering about standardizing on S3 compatible APIs? Users can use tons of services that conform to this standard now, and nostr specific services could expose a compatible endpoint. Users would set their endpoint and keys in settings on the client. Clients could use signed URLs to upload directly.
I though S3 was very Amazon specific?
But yes, users setting API settings sounds the trick. What was that torrent based solution you sent me?
S3 has become such a behemoth that many (most?) other cloud object store providers offer a S3-compatible API so that a customer could migrate from AWS to whatever service with minimal hassle. See:
- https://www.backblaze.com/b2/docs/s3_compatible_api.html
- https://developers.cloudflare.com/r2/data-access/s3-api/api/
- https://cloud.google.com/storage/docs/interoperability
- https://docs.wasabi.com/docs/wasabi-api
- https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm
started a discussion here: https://github.com/damus-io/damus/discussions/272