如何在 ftp 服务器上为 php 使用新的 Azure SDK

How to use the new Azure SDK for php on a ftp server

我现在使用旧的 Windows Azure SDK for PHP (2011)。

require "../../Microsoft/WindowsAzure/Storage/Blob.php";

$accountName = 'resources';
$accountKey = 'accountkey';
$storageClient = new Microsoft_WindowsAzure_Storage_Blob('blob.core.windows.net',$accountName,$accountKey);

$storageClient->blobExists('resources','blob.jpg');

我想升级到新的SDK,但不知道如何手动安装。

网站 运行 在 "Azure Webapp" 通过 FTP。

我设法发现我需要复制 "WindowsAzure" 文件夹,并引用我需要的 类,但是如何?

我按照此页面上的说明进行操作 https://azure.microsoft.com/nl-nl/documentation/articles/php-download-sdk/ 但之后卡住了。

编辑:我没有使用 pear 或 composer 的经验,我想通过 ftp.

手动安装(上传)它

编辑: 现在我得到了以下内容:

require_once('WindowsAzure/WindowsAzure.php');

use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;

// Create blob REST proxy.
$connectionString='DefaultEndpointsProtocol=http;AccountName=ttresources;AccountKey=***************';
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);

$container = '87d57f73-a327-4344-91a4-27848d319a66';
$blob = '8C6CBCEB-F962-4939-AD9B-818C124AD3D9.mp4';

$blobexists = $blobRestProxy->blobExists($container,$blob);

echo $blobexists;
echo 'test';

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); 行阻止了它之后发生的所有事情。


包含 HTTP/Request2.php 后,页面告诉我将 Net/Url2 和 PEAR 包放在我的项目的根目录中(与我的目录相同)加载 windowsazure.php 的页面),它们可以在以下位置找到:

http://pear.php.net/package/Net_URL2/redirected

http://pear.php.net/package/PEAR/download

您可以在 https://github.com/Azure/azure-sdk-for-php 的 GitHub 存储库中获取 PHP 的最新 Azure SDK。然后通过 FTP.

WindowsAzure 文件夹上传到您的 Azure Web Apps

并将 SDK 包含在 PHP 脚本中,例如:

require_once 'WindowsAzure/WindowsAzure.php';

与 PHP 的新 Azure SDK 一样,它需要一些其他依赖项。由于您的脚本在 $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); 处被阻止,您可以检查您是否有依赖项 HTTP/Request2。新的 SDK 利用它来处理 http 请求。

您可能首先需要此依赖项。此外,您可以启用 display_errors 进行故障排除。

而且在新的SDK中,好像没有功能blobExists了。相反,您可以尝试:

// Get blob.
$blob = $blobRestProxy->getBlob("mycontainer", "myblob");
if ($blob) {
   //blob exists
}