0

使用 GoogleCloudStorage 适配器设置 KnpGaufretteBundle 后,我可以在 Google Cloud Storage 中写入文件。

但我不知道如何检索该文件的公共访问链接(在这种情况下为图像)。

这是我用来编写的代码示例,如果它无论如何都相关的话。其实我必须版本:

$fs = $this->get("knp_gaufrette.filesystem_map")->get("bucket_name");
$fs->write("image.jpg",file_get_contents("/path/to/file"));

或者

$file = new \Gaufrette\File("image.jpg",$this->get("knp_gaufrette.filesystem_map")->get("bucket_name"));
$file->setContent(file_get_contents("/path/to/file"));

关于如何从这里检索公共(“http://..”)网址的任何想法?

谢谢!

4

2 回答 2

1

看看 Gaufrette Extra(额外的高夫雷特)。您应该能够通过复制他们为 Amazon S3 执行的方式轻松实现它

于 2018-11-06T19:03:57.593 回答
0

最后,我可以绕过以编程方式获取 url。

首先,我必须像这样公开存储桶: https ://cloud.google.com/storage/docs/access-control/making-data-public

然后我在这篇文章之后得到了网址:

获取文件的公共 URL - Google Cloud Storage - App Engine (Python)

于 2018-11-07T15:16:55.213 回答