cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Impactful Individual
Impactful Individual

Download link for CDS attachments

Hi,

 

I have an entity with attachments (stored in notes).

For now I've been using the attachments control in a gallery to download each file but this has limitations on styling and layout.

Instead I've created a new gallery which shows the name and thumbnail for each attachment and now I want to see if there is a way to recreate the download feature. I know there is a download function but I need a URL for each file.

 

Does anyone know how I can get/build a URL which will download a specific file stored in CDS attachments?

 

Thanks

Sam

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Download link for CDS attachments

The Download function requires a url to a remote file. The API call returns the body as base 64 string and a filename. It's not the actual URL to a file that the Download function expects. I'm not sure you can stream the file on a canvas app directly. Not ideal, but you'll have to call some kind of web service (like Azure Function) to get the file or another option is with Power Automate that saves the file to a temp location and returns in the response the location of the file.

If those two options are not feasible, you might have to rethink about saving the files directly in CDS (which is quite costly btw) and store those in blob storage or SharePoint for example.

Hope this clarifies a little....

View solution in original post

4 REPLIES 4
Highlighted
Super User II
Super User II

Re: Download link for CDS attachments

Hi @SamPo,

You can download the note's attachment via the CDS Rest API directly from the annotation (note) entity. Here's the documentation:

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/reference/entities/annotati...

For example: https://<org>.api.crm.dynamics.com/api/data/v9.1/annotations(b06b2a59-9e23-4e6b-9dd7-98510563b6fa)?$...

 

Hope this helps!

Highlighted
Impactful Individual
Impactful Individual

Re: Download link for CDS attachments

Hi @EricRegnier 

 

Thanks for this! I've managed to use the link to successfully pull the info of the file but when I click the URL it's only showing me the JSON response of the API call in the browser. The question is how do I make this link actually download the file to my PC?

 

2020-05-20_0949.png

 

This is what I have now from the app. Again the info it returns is correct but it just opens up a browser window with the response and doesn't actually save the file.

 

Any ideas?

 

Thanks

Sam

Highlighted
Super User II
Super User II

Re: Download link for CDS attachments

The Download function requires a url to a remote file. The API call returns the body as base 64 string and a filename. It's not the actual URL to a file that the Download function expects. I'm not sure you can stream the file on a canvas app directly. Not ideal, but you'll have to call some kind of web service (like Azure Function) to get the file or another option is with Power Automate that saves the file to a temp location and returns in the response the location of the file.

If those two options are not feasible, you might have to rethink about saving the files directly in CDS (which is quite costly btw) and store those in blob storage or SharePoint for example.

Hope this clarifies a little....

View solution in original post

Highlighted
Impactful Individual
Impactful Individual

Re: Download link for CDS attachments

Got it.

 

Thanks for the advise, I think I might reconsider where I save these files. Just wanted everything to be neatly stored in CDS but seems like it might not be the best option.

 

Thanks

Sam

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (8,669)