How to directly download images and .txt files from sharepoint directly via URL? (more context in the description).

Cabillo, Mark Joseph 5 Reputation points
2023-06-05T13:00:54.32+00:00

What I mean by this is that the "?download=1" trick does not work on image files and .txt files. On image files it just displays the image on browser. On .txt files, it shows nothing. It completely ignores the "?download=1" appended at the end of sharepoint URL. For comparison sake, files like .docx, .csv, and other office files works just fine.

I just want to download the files from sharepoint just by entering the URL in the browser for automation purposes. And its irritating that some filetypes just dont work.

I'm using google chrome as a browser for this.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | OneDrive | For business | Windows
{count} vote

2 answers

Sort by: Most helpful
  1. Yanli Jiang - MSFT 31,611 Reputation points Microsoft External Staff
    2023-06-07T08:42:26.91+00:00

    Hi @Cabillo, Mark Joseph ,

    It is common for images and text (.txt) files to be displayed in the browser instead of downloading when accessed through a URL. The "?download=1" trick may not work for these file types. One possible workaround is to add "&web=1" to the URL instead of "?download=1". This should force the file to download instead of being displayed in the browser.

    However, it is important to note that this workaround may not work in all cases and it may depend on the browser being used. Additionally, you may need to add the SharePoint URL to the list of trusted sites in your browser settings before the download can proceed.

    References:


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Perrotta, Greg (he/him/his) 0 Reputation points
    2024-12-03T15:58:42.9366667+00:00

    Found on a reddit forum:

    "I have been using this without any problem

    https://contoso/teams/site1/_layouts/download.aspx?SourceUrl=https://contoso/teams/site1/lib1/myfile.ext

    I tested using appropriate site/folder/filename parameters and that appears to allow direct download.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.