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

How to create new ImageMessage from remote URL #612

Closed
thomers opened this issue Jul 1, 2024 · 3 comments
Closed

How to create new ImageMessage from remote URL #612

thomers opened this issue Jul 1, 2024 · 3 comments
Labels
question Further information is requested

Comments

@thomers
Copy link

thomers commented Jul 1, 2024

Hello, what's the best way to create a new ImageMessage from a known remote URL (and the "author" attributes of course)?

Both ImageMessage and PartialImage have "size" as required, so should I do a HTTP "head" first and get the content-length from the response headers? Or is there a better / easier way?

@thomers thomers added the question Further information is requested label Jul 1, 2024
@thomers
Copy link
Author

thomers commented Jul 1, 2024

Also: How do I refer to an image from the assets bundle for a ImageMessage?

And to an image that I have downloaded and stored locally manually (in another part of my app)?

@demchenkoalex
Copy link
Member

Hey!

size property is used only to show the size of the image if image is presented as a file message (when image is too large to be presented inline). You can safely pass 0 there. I will make this optional in v2.

As for referring image from local storage, is FileImage good enough? See this code - if uri of the image message does not start with the http it will try to use FileImage to show it. I use it to show images picked from the phone gallery.

@thomers
Copy link
Author

thomers commented Jul 24, 2024

Thanks @demchenkoalex , here's a PR to add support for URIs referencing images from the app's "assets" resources. #619

@thomers thomers closed this as completed Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants