2016-06-07 86 views
0

我正在使用PHP將文件複製到Azure服務上。是否有可能生成一個鏈接,允許用戶使用Office 365在線自動打開此存儲的文檔?目前,返回URL將存儲的文檔下載到用戶本地存儲。這裏是我使用Microsoft Azure PHP SDK的PHP代碼。是否可以使用Office 365在線打開存儲在Azure上的文檔?

require_once 'vendor/autoload.php'; 

use WindowsAzure\Common\ServicesBuilder; 
use MicrosoftAzure\Storage\Common\ServiceException; 

// Create blob REST proxy. 
$connectionString="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); 


$content = fopen("demo.doc", "r"); 
$blob_name = "demo.doc"; 

try { 
//Upload blob 
$blobRestProxy->createBlockBlob("mycontainer", $blob_name, $content); 
} 
catch(ServiceException $e){ 
// Handle exception based on error codes and messages. 
// Error codes and messages are here: 
// http://msdn.microsoft.com/library/azure/dd179439.aspx 
$code = $e->getCode(); 
$error_message = $e->getMessage(); 
echo $code.": ".$error_message."<br />"; 
} 

回答

1

默認情況下,Office 365無法打開存儲在其他位置(不在Office 365中)的文件。但是,您可能會嘗試使用WOPI協議與Office Online集成。 WOPI協議使Office Online能夠訪問和更改存儲在服務中的文件。

另一個解決方法是,你可以考慮把文件上傳到Office 365的你也可以參考下面的REST創建/上傳項目到SharePoint在線:

POST: https://graph.microsoft.com/v1.0/me/drive/root/children 
authorization: bearer {token} 
content-type: application/json 
{ 
"name":"filename.docx", 
"file":{} 
} 

PUT: https://graph.microsoft.com/v1.0/me/drive/root:/RESTFei.docx:/content 
authorization: bearer {token} 
Content-Type: application/msword 

<@INCLUDE *C:\Users\username \Desktop\test.docx*@> 

更多細節是關於微軟開發圖形,請參閱here

相關問題