Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Fog gem:如何创建子目录?_Ruby_Fog_Fog Aws - Fatal编程技术网

Ruby Fog gem:如何创建子目录?

Ruby Fog gem:如何创建子目录?,ruby,fog,fog-aws,Ruby,Fog,Fog Aws,我有 有没有一种方法(有文档的、无文档的、变通的)可以让我在这个bucket中创建目录?比如: connection = Fog::Storage.new(fog_config) bucket = connection.directories.get(bucket_name) 在S3中,带有尾随斜杠的零字节文件将创建一个伪目录。这将导致文件夹出现在AWS浏览器UI中 对于fog,将nil传递到body参数将创建一个空文件。下面的代码将创建一个子目录 sub_dir_for_us

我有

有没有一种方法(有文档的、无文档的、变通的)可以让我在这个bucket中创建目录?比如:

  connection = Fog::Storage.new(fog_config)
  bucket     = connection.directories.get(bucket_name)

在S3中,带有尾随斜杠的零字节文件将创建一个伪目录。这将导致文件夹出现在AWS浏览器UI中

对于fog,将nil传递到body参数将创建一个空文件。下面的代码将创建一个子目录

sub_dir_for_user_1 = bucket.create_sub_dir('/user_1_files')
sub_dir_for_user_2 = bucket.create_sub_dir('/user_2_files')

AFAIK Amazon S3没有目录的概念,它是一个平面文件系统。目录仅在浏览器UI中显示是为了方便。是的,S3中没有真正的目录,只有长路径(在某些上下文中,斜杠表示的前缀被视为类似于子目录)。
bucket.files.create(
  key: 'user_1_files/',
  body: nil
)