Вопрос

I need to download a file which is in SharePoint online programmatically. The link I have is in this format:

https://xxxxx.sharepoint.com/:f:/g/EkcBNxpXTKZJrg3xdBWlFBEBlgVj4FInALm_JVs4kYfK8w?e=tPfJVv

All the posts I can find refer to editing the URL from guestaccess.aspx to download.aspx, but that doesn't work for a URL in this format.

I'm trying to download the file in an AutoIT script, which will be available to a lot of users.

The link allows the file to be downloaded, but only by clicking the download button in Excel Online after the file is opened in a browser.

Is there any way I can do this? Amending the URL? Creating a different type of link in SharePoint? Or using any API?

Это было полезно?

Решение

Thanks for the response Lee_MSFT. I couldn't get your suggestion to work, but I got an answer on another forum.

I replaced everything after the last '?' with 'download=1'. Then the link can be used in my code to pull the file down.

Thanks for your help.

Другие советы

When you request the anonymous link, user will be redirect to a URL with sourcedoc parameter, then you could download the file by download.aspx with UnqiueId parameter.

`https://xxxxx.sharepoint.com/:f:/g/EkcBNxpXTKZJrg3xdBWlFBEBlgVj4FInALm_JVs4kYfK8w?e=tPfJVv`

    ?sourcedoc=%7B86036808-bc2f-4c4f-8c02-44f2f9fec10b%7D&action=default

    https://tenant.sharepoint.com/sites/Developer/_layouts/15/download.aspx?UniqueId=sourcedoc=%7B86036808-bc2f-4c4f-8c02-44f2f9fec10b%7D

I have used 'download=1' to direct download a public file in SharePoint. It is working fine but this is working for .docx, .xlsx & .zip files only, it is not working for images & .txt file. So i have used following option & it is working for all files.

Public URL: https://xxxxx.sharepoint.com/:f:/g/EkcBNxpXTKZJrg3xdBWlFBEBlgVj4FInALm_JVs4kYfK8w?e=tPfJVv

you need to get file Unique id from this URL i.e. EkcBNxpXTKZJrg3xdBWlFBEBlgVj4FInALm_JVs4kYfK8w

and update URL to:

https://xxxxx.sharepoint.com/sites/Developer/_layouts/15/download.aspx?share=EkcBNxpXTKZJrg3xdBWlFBEBlgVj4FInALm_JVs4kYfK8w

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top