Attachement url for html_widget

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 !
:+1: :+1:

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