2016-06-07 60 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

相关问题