Ruby Fog gem: how to create subdirectories?

I have

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

Is there a way (documented, not documented, workaround) to create directories inside this bucket? Sort of:

 sub_dir_for_user_1 = bucket.create_sub_dir('/user_1_files') sub_dir_for_user_2 = bucket.create_sub_dir('/user_2_files') 
+4
source share
1 answer

In S3 files with a null byte with a trailing slash, a pseudo-directory is created. This will cause folders to appear in the AWS browser interface.

For fog passing nil to the body argument, an empty file is created. So the following code will create a subdirectory ...

 bucket.files.create( key: 'user_1_files/', body: nil ) 
+2
source

All Articles