0

I am new to both of these technology and taking this opportunity to learn and explore them.

I have a situation where on button click event, I am suppose to put data into a file and allow user to download it. The output file should be in doc format. I tried using blob, below is the code but that too didn't helped:

app.config(['$compileProvider',function($compileProvider)}
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|blob:/);
}]);
var content = 'file content for example';
var myBlob = new Blob([content],{type:'application/msword'});
var fileURL = window.URL.createObjectURL(myBlob);
$scope.url = $sce.trustAsResourceUrl(fileURL);

By using above code I am getting following error:

unsafe:blob:GUID number

We are using Sharepoint 2013 and angular.js-1.2.28

I need help/guidance in solving this issue

We are using JSOM api and file doesn't exist in Sharepoint.

I appreciate your help in advance.

I am sorry for basic question, as I said I am still learning.

  • 1
    Please explain the complete use case. How this relates to SharePoint? Is the file already exists in SharePoint and you are trying to modify it? Are you using SharePoint REST or JSOM API? – Amal Hashim Aug 4 '16 at 22:12
0

Triggering a file download from AngularJS is not different to triggering a file download from pure old JavaScript. Use simply window.open(UrlOfYouDoc) in your event handler. window.location = UrlOfYouDoc; should work as well, but we use the first version in our AngularJS event handler function.

UrlOfYouDoc is the URL address of your word document. In our case its generated on the server side dynamically in an .ashx, but of course it can be a "static" .docx as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.