-
-
Notifications
You must be signed in to change notification settings - Fork 607
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 upload an image from a URL #1107
Comments
This issue tracker is not a great place to get support - please visit #matrix-dev:matrix.org instead to get some help with the js-sdk. |
@BurnyBoi I was also having the same issue. I was finally able to get the
|
You need to add in opts { onlyContentUri: false } |
Why give a hint to a chat group and not improve or at least check the documentation and close it? |
This is horrible. Why does it need so much manual work? The bot sdk is even worse. Why can't it be a single line to upload an image? That's a very common use case. |
Because downloading an image isn't easy in certain Javascript environments. Like web with CORS. |
How does that influence poor sdk design? |
The SDK has no consistent cross platform way to download an image that wasn't uploaded to matrix to begin with. So you need to download it yourself. As for why uploading content and sending an event is separate is that it's very different for encrypted events. So having a single method only usable for unencrypted events would be very inconsistent SDK design. |
You know in Discord it only takes a single line: https://discordjs.guide/popular-topics/embeds.html#using-the-embed-constructor You only need to give it a link to the image you want to embed. Why can't matrix do it? |
Discord doesn't support encryption. Discord can also have their server accept a url and just use that as media. Matrix API doesn't support that. Makes for a much thicker SDK. They're not really comparable other than on the UX or surface level. |
I don't get it, what does encryption change here? It's unrelated to SDK or API design. |
Encryption requires you to generate a thumbnail or poster frame client side which is very difficult to do in one way cross platform. Super easy to do in the web, hard to do in Node or Deno which can't render these medias. The SDK has wide Javascript runtime support which means it doesn't have web specific or node specific or any other specific code. |
Unless you want an api which looks like Client.sendImage(downloadFn, thumbnailFn, room Id) Where you pass callbacks on how to perform the download and thumbnailing in your specific environment. |
Why can't the server do it? This is not my problem, as a consumer of the API. |
The server can't generate thumbnails for encrypted media to which it has no keys. That's the whole point of end to end encryption. |
How about in rooms with no encryption? That seems like a serious anti-feature |
@nukeop in such a case a one-liner doing both upload (local file/buffer) and send would be feasible, but having to use a very different API depending on if a room is encrypted or not sounds like poor SDK design. As for the case of wanting the SDK to handle uploading files from a URL it'd want something like matrix-org/matrix-spec-proposals#2370 |
Similar to what is being done in #238, I am trying to take an image url, and pipe the image into uploadContent(). Here is what I am testing with:
When I run this, it runs the command without any errors, but the message does not have the image, just a blank file:
Attempting to click download does not show the file either. It just says: "The image cannot be displayed because it has errors." Could I get some clarification on how to accomplish this?
The text was updated successfully, but these errors were encountered: