Options for editing MS Word documents in Azure Storage
Asked Answered
W

1

10

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?

Weariful answered 1/3, 2017 at 2:9 Comment(2)
People who down vote a question without even having a courtesy to explain why are ....Weariful
Hi, have you found a solution for this? Have you tried SAS (Shared Access Signatures)?Philibeg
B
6

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.
Bryophyte answered 2/3, 2017 at 9:17 Comment(2)
Have you tried my suggestions? If my reply is helpful for you, please mark it as answer. Thanks.Bryophyte
Can this be achieved with Node + Express API? I have built an app and it requires the same functionality. How do I upload a copy of the document from Azure Storage to OnedDrive using my API without having to log in?Fencesitter

© 2022 - 2024 — McMap. All rights reserved.