Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [HttpGet]
- public async Task<IHttpActionResult> Download(Guid customDocId)
- {
- byte[] responseContent = await Task.FromResult(FileNetApiClientFactory.Get(customDocId).DownloadDocument(customDocId, "pdf", true));
- HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK)
- {
- Content = new ByteArrayContent(responseContent),
- StatusCode = HttpStatusCode.OK,
- };
- response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = string.Concat(customDocId.ToString(), ".pdf") };
- response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
- return ResponseMessage(response);
- }
- //saveAs method is from FileSaver.js
- vm.download = function () {
- documentService.download($scope.customDocumentId).then(function (fileData) {
- var blob = new Blob([fileData], { type: 'application/pdf' });
- saveAs(blob, $scope.customDocumentId + ".pdf");
- }).catch(function () {
- });
- }
- function _download(customDocumentId) {
- return Restangular
- .one('customdocument', customDocumentId).one('download')
- .get(null, { responseType: 'arraybuffer' });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement