duan246558 2016-06-07 16:05
浏览 44
已采纳

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

I am copying files using PHP onto an Azure service. Is it possible to produce a link that will allow a user to automatically open this stored document using Office 365 online? Currently, the return URL downloads the stored document to a users local storage. Here is my PHP code which uses the Microsoft Azure PHP SDK.

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条回答 默认 最新

  • dongzhang1839 2016-06-08 06:02
    关注

    The Office 365 is not able to open the file which store on other place( not in Office 365) by default. However, you may try to use the WOPI protocol to integrate with Office Online. The WOPI protocol enables Office Online to access and change files that are stored in your service.

    Another workaround is that you can consider upload the file to Office 365. And you can refer to the REST below to create/upload item to SharePoint online:

    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*@>
    

    More detail about developing with Microsoft Graph, please refer to here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝