Open lctone opened 2 years ago
Hi! Did you solve this? I need to fetch the image from another editorjs instance in another application with another domain and was wondering the same hehe
The reason I didn't set absolute URL to the output for the images is because the portability, and if you already access it through the API, then for sure you are aware with the domain, so you simply could put it.
Anyway, as this seems to be asked more often, I can think of adding a URI property (which will be quite ease) with absolute address, the only think I am not sure if it's good or not is to add field for a static token or not.
Wow fast response! I think it could be interesting to add the ability to manually do it, but maybe not necessary if there is a way to handle it dynamically.
How is the url constructed today? I’m thinking, if it’s possible, to use the configuration invironment variable PUBLIC_URL (or maybe some other unknown to me better variable) and then append the path to assets and image. In that way, it would be reachable from another application. But maybe that’s the way it’s constructed today?
Well, internally it uses the {baseUrl}/assets/{file.id}
(according the docs), where the baseUrl is PUBLIC_URL
env as you already mention.
And for token it uses the current user's token, which is not good idea to be added to the output because of possible leakage.
Anyway, it might be really good idea to add it to the final output as separate uri
or guid
property with an optional static token configuration field, I'll try to do it in next days.
Okey haha, lucky guess from my side.
just to be clear, when you say “add it to the final output as separate uri“ are you referring to adding the complete uri of the image, including the baseurl to a different key in the image meta-data structure? Because I’m thinking this: What if one of the editors is in a directus invironment, and the other editor is used in an angular project, wouldn’t it be better if the image url is always stored as the complete uri? that way both editors would work without having to convert the image path.
but maybe I’m missing something here
Yes, there are couple of cases where this is not the most suitable, for example:
So in such cases, it might be more reliable to use fileId
or url
Ah yes. that is correct... didnt think of that
Also editor.js requires full path:
file - uploaded file data. Must contain an url field with full public path to the uploaded image. Also, can contain any additional fields you want to store. For example, width, height, id etc. All additional fields will be saved at the file object of output data.
Hello guys,
I want to config domain to image path URL
Image data save right now /assets/c99aa974-6132-4a6a-8442-5c1e162454a8
Config save to this https://domain.com/assets/c99aa974-6132-4a6a-8442-5c1e162454a8
Great extension, Thank you