Forum Discussion

Mike Jansen's avatar
Mike Jansen
Iron Contributor
Jul 04, 2017
Solved

Save generated .xml file to Azure, using javascript

I have some client site javascript which creates an .xml structure. This works fine. Now I want to save this as a file to an Azure server.   Is this possible (as I am using client site scripting)? ...
  • Ronald Borman's avatar
    Jul 15, 2017

    Hi Mike,

     

    Long time no see...

     

    Assuming you want to use Azure File Service, you could use REST operations with jQuery Ajax or fetch (browser native or polyfill).

     

    See https://docs.microsoft.com/en-us/rest/api/storageservices/file-service-rest-api for the HTTP request format and required headers. In the case of saving a file it is a two step process: 

    - Create File;

    - Put Range.

    BTW it looks like the API description for Put Range is incomplete, because you would expect that the actual contents should be specified in the HTTP body.

     

    There is a security tradeoff however. You have to create a shared access signature with a shared key and that key is visible when you only use client side scripting. See https://www.kongsli.net/2011/03/16/creating-azure-blob-storage-shared-access-signatures-using-javascript/ for more information.

Resources