SOLVED

Save generated .xml file to Azure, using javascript

Regular Contributor

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)? What might be the best approach?

 

Thanks, Mike

1 Reply
best response confirmed by Mike Jansen (Regular Contributor)
Solution

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-javasc... for more information.