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


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,但不知道如何手动安装它。

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

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

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

编辑:我没有梨或作曲家的经验,我想通过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

你可以在 GitHub 存储库上获取最新的 Azure SDK for PHP https://github.com/Azure/azure-sdk-for-php。然后通过 FTP 将WindowsAzure文件夹上传到 Azure Web 应用。

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

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
}