Add document to downloadFile-method

Simple copy/paste to document a useful method
This commit is contained in:
Søren Gregersen
2020-03-25 19:23:29 +01:00
committed by Sebastiaan Janssen
parent 972acc6718
commit a0e5b83914
@@ -365,12 +365,23 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
},
/**
* @ngdoc method
* @name umbraco.resources.contentResource#downloadFile
* @methodOf umbraco.resources.contentResource
*
* @description
* Downloads a file to the client using AJAX/XHR
* Based on an implementation here: web.student.tuwien.ac.at/~e0427417/jsdownload.html
* See https://stackoverflow.com/a/24129082/694494
*
* @param {string} httpPath the path (url) to the resource being downloaded
* @returns {Promise} http promise object.
*/
downloadFile : function (httpPath) {
/**
* Based on an implementation here: web.student.tuwien.ac.at/~e0427417/jsdownload.html
* See https://stackoverflow.com/a/24129082/694494
*/
// Use an arraybuffer
return $http.get(httpPath, { responseType: 'arraybuffer' })
.then(function (response) {