Url for attachments

Is there an url I can use in the browser to download an attachment directly? Ie get the same results as when clicking download on an attachment on a comment?

Or if I want to link to an attachment already attached on a comment (eg “Test 1.pdf”) from another new comment I’m writing (without downloading the attachment and uploading it to the new comment), what url can I use?

image

1 Like

I will investigate and report back. We don’t have the same level of data normalisation for uploaded blobs as we do for Speckle objects. Still, you should be able to do this in code (as you have already been doing with other Comment experiments), but it is not currently possible from the web UI.

It is an interesting question that hasn’t come up before. Is this to avoid fresh uploads?

Thanks!

Oki, so if I have a blobid, can I use that to create a url (in code) that goes directly to the blob?

What do you mean with fresh uploads?

We have eg an image which describes several objects present in the model. We would like to make a comment on each object and on the comment link to the same image (instead of uploading the same image several times to different comments).

Yes, if you are programmatically creating the comments, they can all refer to the same uploaded blob.

Aha great! What does that url look like?

From a query of:

query {
  comment(streamId:"{{STREAM_ID}}", id:"{{COMMENT_ID}}") {
    text {
      attachments {
        id
      }
    }
  }
}

Gives a response of:

{
  "data": {
    "comment": {
      "text": {
        "attachments": [
          {
            "id": "{{BLOB_ID}}"
          }
        ]
      }
    }
  }
}

That id you’ll notice is the blobId you may have used to comment in the first place.

The actual URL to download will be:

https://speckle.xyz/api/stream/{{STREAM_ID}}/blob/{{BLOB_ID}}

Should I be able to put that url in a comment and when clicking it, it should download the blob?

When I try I get "error":"Cannot validate role without auth"

Not the URL, no, but if you add an attachment with the blobId then yes, clicking on the attachment will show a preview and allow for download.

Okay I see, so it will only be possible to link to a blob from comments (created from code) in Speckle, not from eg another app?

No, there is no mechanism for doing so at this time.

Sanitizing cross-site content can be tricky but clearly not impossible. Hence you can reference images in posts here, but we’d need to be clear about what to allow/disallow.

Could you describe what the use case would be for this? Direct reference to a specification/image on another site?

Oki, yes understand.

Yes, direct referencing from another site was the use case we had in mind. To get directly to the specification/image without needing to go via the link in the comment. Is it possible to have image thumbnails of the links instead of text in the comments by the way? Maybe that or something similar would be an option…

We’re in the thick of testing the upcoming 2.14 release, but I will investigate options around this as soon as possible!!

1 Like