How to get url or an Attachment

I need to get url or the attachment.

But Im only able to get file name and id.

It seems like this isn’t possible to gather from within a view js/ts. But, if you are generating an attachment in cloud code you can gather this information. Would be a good feature request.

As @alex-valdez correctly mentioned you can retrieve the URLs from CloudCode, but you can also retrieve them via the Backend API.

Photo and Signature attachments will have original, fullscreen and thumbnail URLs, generic file attachments will just have the original URL. Signature attachments will also include an additional svg URL. (In CloudCode there is a helper method called url() that can be called on any attachment to retrieve its original url. The method will return null if the attachment has not yet been uploaded)

Attachment URLs will only be available once the attachment has been uploaded, so it is recommended to check for a "state": "uploaded" before trying to access the URLs. (In CloudCode there is a helper method present() that can be called on any attachment to check if the the upload has been completed or not)

Assuming a job object with a photo attachment, the URLs can be accessed from CloudCode as follows. Please note that in CloudCode the

CloudCode

var job = await DB.job.first();
// Option 1
if (job.photo.state === 'uploaded') {
   var original = job.photo.urls.original;
}

// Option 2
if (job.photo.present()) {
   var original = job.photo.url();
}

If you are retrieving the URLs via the backend API then you will also need to check the state before expecting any URLs, but you can expect the same URLs to be present. For the field presentation of attachments that are retrieved via the Backend API please see the documentation here.