Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options for editing MS Word documents in Azure Storage

This question follows on from a previous question that went unanswered.

I've got a requirement in an Azure web app to edit a Document, instead of:-

  1. Downloading the file
  2. Open the downloaded file in MS Office Word
  3. Editing and saving it locally
  4. Clicking a button on a web form
  5. Browsing to the edited file and then clicking OK to upload it

The client would like an experience similar to what you get in Sharepoint i.e.

  1. Click a link to a word document
  2. MS Office Word starts on the client
  3. They edit and save the (online) document

One solution I've found is...

Store the Documents in a Azure File Share. Create a login script which would run on every windows client access to set the user name and password for the Azure File Share....

cmdkey /add:<storage_account>.file.core.windows.net /user:AZURE\<storage_account> /pass:<storage_account_key>

Use links in the html like...

<a href='file://///<storage_account>.file.core.windows.net/<storage_container>/test.docx'>Test.doc</a>

There's a number of issues with this.

  1. It's not a cross browser solution. Whilst this link will cause MS Office Word to be launched and load the document successfully in Firefox and Internet Explorer, it doesn't work in Chrome (which downloads file) and Edge (which doesn't process it at all).
  2. It's inherently insecure, requiring a single set of credentials being distributed to all the clients that need to access the system.

Can anyone suggest alternative solutions?

like image 497
Mick Avatar asked Mar 01 '17 02:03

Mick


People also ask

What are correct options for Azure storage?

Azure Blob storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data, such as text or binary data. Blob storage is ideal for: Serving images or documents directly to a browser.

How do I edit a Word document in the cloud?

To edit, click Edit Document in the top left corner and select Edit in Word Online. The document will then open in the editor and allow you to make changes to the document. To edit a document with Word on your desktop, select Edit in Word when in the Read Only version of your OneDrive document.


1 Answers

Options for editing MS Word documents in Azure Storage

To edit MS Word document online, That saving the Word document to OneDrive is a good choice. OneDrive will provide a link for the file which we uploaded and we could view and edit the file based on this link.

Here are the detail steps.

  1. Read the MS Word document which you want to edit from Azure Storage.
  2. Save this document to OneDrive folder using OneDrive API and get the link from the response. Here is the HTTP request message which I used to upload file to OneDrive.
PUT https://graph.microsoft.com/v1.0/drive/root:/Documents/{filename}.docx:/content HTTP/1.1
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Authorization: Bearer {your token}
Accept: application/json
Host: graph.microsoft.com
Expect: 100-continue
Connection: Keep-Alive

Put your file content here

We can get the link for the file from the webUrl property of response JSON object. It is like this,

"webUrl": "https://1drv.ms/w/s!AI164yLtIBq0gSA"

For more information, link below is for your reference.

Simple item upload to OneDrive using PUT

  1. Add web hook to your OneDrive folder. If anyone edit the file online, a message will be sent to your method and you can download the updated file and save to your Azure Storage. Here is a sample HTTP request message
POST /subscriptions
Content-Type: application/json

{
"notificationUrl": "https://xxxx.azurewebsites.net/api/webhook-receiver",
"expirationDateTime": "2018-01-01T11:23:00.000Z",
"resource": "/me/drive/root",
"changeType": "updated",
"clientState": "client-specific string"
}

For more information, link below is for your reference.

WebHooks - Adding a new subscription

  1. Delete files from OneDrive folder if the folder is full.
like image 123
Amor Avatar answered Oct 12 '22 09:10

Amor