使用 php 在桶谷歌云存储中创建文件夹

编程入门 行业动态 更新时间:2024-10-09 22:18:44
本文介绍了使用 php 在桶谷歌云存储中创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对谷歌云存储很陌生.

I am very new to the google cloud storage.

我想使用 php 编码在存储桶中创建文件夹.我搜索了很多网站,在 1 上我看到它是这样写的:

I want to create folder in bucket using php coding. I have searched a quite few sites and on 1 i saw it was written:

"在存储桶中创建文件夹将创建一个以目录命名的占位符对象,没有数据内容,mimetype 为 application/x-directory.不支持在 Google 存储管理器中创建的目录占位符对象."

"Creating a folder inside a bucket will create a placeholder object named after the directory, has no data content and the mimetype application/x-directory. Directory placeholder objects created in Google Storage Manager are ​not supported."

我不明白它想说什么.我该如何创建文件夹,请帮帮我.我尝试使用以下代码:

I could not understand what it is trying to say. How can i create folder please help me out. I tried using the following code:

$req = new Google_HttpRequest("commondatastorage.googleapis/bucket/myfoldertrial"); $req->setRequestHeaders(array( 'x-goog-project-id' => 21212, 'x-goog-acl' => 'public-read', 'Content-Type' => 'application/x-directory' )); $req->setRequestMethod('PUT'); $req->setPostBody('myfoldertrial');

我正在使用以下链接中的 API:

I am using the API from following link:

Google API for PHP

请帮助我使用 PHP 创建文件夹.

Please help me out creating folder using PHP.

推荐答案

您可能实际上不需要创建文件夹.

You probably don't actually need to create a folder.

Google Storage 不像您的操作系统的文件系统使用的树形结构,所有对象都存储在顶层的存储桶中.但是,您可以为对象命名,其中包含斜线,因此它看起来像是在文件夹中 - Users/username/docs/2012/09/21/activity.csv 是对象的完美名称,不需要任何支持文件夹.

Google Storage isn't a tree structure like your operating system's filesystem uses, all Objects are stored in buckets at the top level. However you can give an Object a name with slashes in it, so it will kind of look like it is in a folder - Users/username/docs/2012/09/21/activity.csv is a perfectly good name for an Object and doesn't need any supporting folders.

一旦你有了这种方案的对象,你就可以列出它们,就像你正在查看带有 delimiter 和 prefix 的文件夹的内容一样这些文档的参数.

Once you've got Objects with this sort of scheme in place, you can list them as if you were viewing the contents of a folder with the delimiter and prefix parameters as per these docs.

所以如果你只想创建 myfoldertrial 这样你就可以上传 example.png 进去,不需要创建文件夹,你可以直接上传到 myfoldertrial/example.png.

So if you only wanted to create myfoldertrial so you could upload example.png into it, there's no need to create the folder, you can just upload straight to myfoldertrial/example.png.

更多推荐

使用 php 在桶谷歌云存储中创建文件夹

本文发布于:2023-11-24 14:02:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   php   桶谷歌云

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!