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

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

我对Google云存储非常陌生.

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 Storage Manager中创建的目录占位符对象.

"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:

适用于PHP的Google API

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

Please help me out creating folder using PHP.

推荐答案

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

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

Google存储空间不是操作系统所使用的文件系统那样的树形结构,所有对象都存储在顶层的存储桶中.但是,您可以给对象起一个带斜线的名称,因此看起来就像在文件夹中一样-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参数那样查看文件夹的内容一样列出它们,以列出它们: //developers.google/storage/docs/json_api/v1/objects/list>这些文档.

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在存储桶Google云存储中创建文件夹

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

发布评论

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

>www.elefans.com

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