Search code examples
rubyfog

How to determine if a Fog-uploaded cloud-storage file is public?


I have a Ruby method that calls:

FOG_DIRECTORY.files.create(
    key: cloud_filename,
    body: File.open(local_filename),
    public: public_boolean)

Is there a way to then do something like:

CLOUD_DIRECTORY.files.get(cloud_filename).public

to see if the file is publicly viewable or not? I'm using S3 and could always check the S3 path but then I have to deal with code to look at files at remote URLs and, more importantly, I reduce this code to being S3-dependent, rather than easily portable.


Solution

  • There doesn't seem to be a separate method to check this, but you can check if #public_url returns nil or not. See the source.