是否可以使用 Office 365 联机打开存储在 Azure 上的文档



我正在使用PHP将文件复制到Azure服务上。是否可以生成一个链接,允许用户使用 Office 365 联机自动打开此存储的文档?目前,返回 URL 将存储的文档下载到用户的本地存储。这是我使用Microsoft Azure PHP SDK的PHP代码。

require_once 'vendor/autoload.php';
use WindowsAzureCommonServicesBuilder;
use MicrosoftAzureStorageCommonServiceException;
// 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 />";
 }
默认情况下,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:Usersusername Desktoptest.docx*@>

有关使用 Microsoft Graph 进行开发的更多详细信息,请参阅此处。

最新更新