Dears,
I’m trying to include in html_widget an .png logos stored in column A
I have retrived the “hard” url with the browser help :
<img src="https://doc-worker-172-31-21-195.getgrist.com/dw/doc-worker-172-31-21-195/v/f937d4d7e/o/docs/attachment?clientId=XXXXXXXX&docFD=0&ident=5b711db22bcdefc55a5ec30aa0a7136c586b16f3.png&XXXXXX" alt="" width="240" height="90" />
Is there a way to do this without putting the hardlink so that change in column A will follow in the html_widget ?
1 Like
Hi @Sylvain_Page - attachments are currently hard to access safely from custom widgets. There’s an update coming very soon to resolve this. Watch this space!
If your document happens to be publicly viewable, then you can use image source urls like https://docs.getgrist.com/api/docs/DOCID/attachments/NNNN/download
where NNNN are the ids stored in the attachment column (in your table they’d be available as $A.id). But most docs aren’t publicly viewable, and access to the attachment columns from a custom widget will be denied - hence the update we are working on.
Hi @paul-grist , Thanks for your answer and explanation.
Happy to see you have plans for this issue.
Hello Grist Team,
I still admire your concept for grist, the effort you put on, the patience you have to answer everybody.
Congratulations !
I’d like to know if this topic (accessing attachement, mainly image in custom widget) is still on the roadmap ? Do you think it would be availble in less than three month ?
I can wait untill there and it would save me some work but if it is clearly not planned I have to find a work around.
1 Like
Hi @Sylvain_Page, sorry for the delay in responding. A method of accessing attachments within custom widgets has been developed, reviewed, approved, and should be available next week. I’ll post with the details once they are released.
2 Likes
No problem ! You have lots of request !
Thanks to grist-team !
Hi @Sylvain_Page, there is now a grist.getAccessToken()
function available in custom widgets, which gives you a token you can append to attachment urls. There is a usage example at grist.getAccessToken. I’d say we could polish this further to simplify use cases like yours, but at least there should be a solid way to do it now. Hope this helps.
Hello @paul-grist ,
I’m not enough skilled in JS & token to realize that for the moment.
I’ll keep an eye on it maybe later, anyway this is as you said a first step.
thanks
Hi Paul. But that must be included in the widget?
But Sylvain (and I now) are trying to use the standard HTML widget to show an attached image. How to deal with this?
Wouldn´t maybe be easier to have a checkbox at attachments to tell if that attachment is public? Hmmm, actually that also brings the problem that attachment columns may have several attachments. How will the HTML show a single one…
Hi Rogerio,
For me I ended-up serving my own custom widget on the same server that serve Grist.
With this I do not have anymore CORS issue.
I use markdown widget(can be html as well) and just link my image.
As far as I understood each attachment have its own number.
As being in a secure environnement I put public on the document and link the image this way.
http://192.168.1.25:8484/api/docs/19m2NaviymoD/attachments/399/download
Also I am 100% inside my LAN and no data sent outside.
Yes, I need to clone the Grist plugins to my internal network… do you have any idea on how to do that or some topic discussing the steps to take, so Grist will access them instead of the plugins on the cloud?
But regarding the topic, it’s another Grist workspace (a personal project) that is located on the Grist cloud, not my company internal network.
Hi,
I cloned grist-custom widget repository (zip download + unpack but git is certainly better).
To serve those doc I used W10 IIS as it is very simple to configure.
If I were on linux, having no experience on running small standalone static server, I would try to use lighttpd : TutorialConfiguration - Lighttpd - lighty labs
The goal is to serve index.html of the folder file of your plugin
Then I put everything in c:\Grist_Plugins.… (all the custom_widget folder)
then my access is then something like that → http://192.168.1.25/markdown (serving on port 80)
Hope it helps.
on your case, you must insert the URL of the Widget? It stops working with the simple selection method?
Yes URL must be inserted.
With Grist-Desktop, I am currently facing an issue with latest update, but I guess that with standard docker image it still work.
So normally you keep both choice :
- entering custom url (local custom_widget with no CORS issue)
- choosing Grist github repository but with CORS issue.
small screenshot