【问题标题】:Write text file to Blob in Azure using PHP使用 PHP 将文本文件写入 Azure 中的 Blob
【发布时间】:2012-06-05 18:11:18
【问题描述】:

我正在尝试将文本文件写入 blob。我知道我必须创建一个容器和一个 blob。我需要这样写:

$text = 'some text';
$myFile = "file.txt";
$fh = fopen($myFile, 'w') or die("can't open file c");
fwrite($fh, $json);
fclose($fh);

问题是我想写这个 php 脚本但使用 blob(我们无权访问系统文件)我该怎么做?

【问题讨论】:

  • 但是...?问题出在哪里?
  • 我想编写相同的脚本,但它不适用于 azure,我无权访问文件系统。

标签: php azure azure-storage azure-blob-storage


【解决方案1】:

将文件保存到磁盘后,您需要将其上传到容器:

_storageClient->putBlob('mycontainer', 'file.txt', 'file.txt');

您可以使用 Windows Azure PHP SDK 来做到这一点。关注本教程了解更多信息:Put a Blob in a Blob Container

【讨论】:

  • 但我怎样才能在文件中写入/附加文本?
  • 我该如何做 fwrite 部分?我只能提供文件路径,不能提供内容
猜你喜欢
  • 2014-09-09
  • 1970-01-01
  • 2019-11-27
  • 2021-05-02
  • 2013-04-04
  • 1970-01-01
  • 2015-06-20
  • 2011-03-23
  • 2020-04-18
相关资源
最近更新 更多