Re: S3 and "subdirectories"

968 views
Skip to first unread message

Rupak Ganguly

unread,
Mar 28, 2013, 5:21:40 PM3/28/13
to ruby...@googlegroups.com
Hi Pierre,

Thanks,
Rupak Ganguly
Ph: 678-648-7434


On Thu, Mar 28, 2013 at 4:52 PM, Pierre Carrier <pierre....@airbedandbreakfast.com> wrote:
Hi,


I'm trying to use the nice Fog abstractions, but it looks like I'm missing a feature.

Context
=======

I'm simulating subdirectories in an S3 bucket through a structure like this:

ex/a
ex/b
ex/c/
ex/c/d
ex/c/e

ex/c/d and ex/c/e are in the ex/c "subdirectory".

Problem
=======

With Fog::Storage::AWS::Directory, it seems one cannot list that "ex/" contains "ex/a", "ex/b" and the "subdirectory" "ex/c/".

Only the files can be listed:
> puts Fog::Storage[:aws].
  directories.get('hello').
  files.all(prefix: 'ex/', delimiter: '/').collect do |f|
    f.key
  end.join ', '

ex/, ex/a, ex/b

Amazon API
==========

If I were to issue a direct call, I could actually see the files and subdirectories:

> r = Fog::Storage[:aws].get_bucket('hello', prefix: 'ex/', delimiter: '/').data[:body]

> puts r['Contents'].collect {|c| c['Key']}.join ' '
ex/ ex/a ex/b

> puts r['CommonPrefixes'].join ' '
ex/c/

Wrap-up
=======

I don't think those "subdirectories" are exposed in the nice Fog::Storage::AWS::Directory API.
If they are already, I'd appreciate a pointer.
If they aren't, is that something you'd consider?


Thanks,

-- 
Pierre

--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

geemus (Wesley Beary)

unread,
Mar 29, 2013, 10:36:40 AM3/29/13
to ruby...@googlegroups.com
That is correct, we don't pull common prefixes up into the models. If you need that I would probably just fall back to the requests at least for now. Perhaps we should expose that somehow though, as an additional attribute or something. I'd be open to discussion and/or helping out if somebody wanted to work on that (just open an issue on the project at https://github.com/fog/fog/issues/new).

Pierre Carrier

unread,
Apr 8, 2013, 5:23:35 AM4/8/13
to ruby...@googlegroups.com
Actually, I started digging into the code base to writing a patch, and it turns out they do get exposed, even though not in a "processed" form.

A git blame later, turns out you implemented this support back in 2010 :)


Fog::Storage[:aws].
  directories.
  get('hello', prefix: 'ex/', delimiter: '/').
  files.
  common_prefixes

=> ["ex/c/"]


Thanks,

-- 
Pierre

geemus (Wesley Beary)

unread,
Apr 8, 2013, 11:15:51 AM4/8/13
to ruby...@googlegroups.com
Great, glad you figured out what you needed. Apologies I couldn't just tell you that, my memory isn't what it once was ;)


Thanks,

-- 
Pierre

--
Reply all
Reply to author
Forward
0 new messages