class Fog::Storage::GoogleJSON::File
Constants
- FILE_INSERTABLE_FIELDS
- VALID_PREDEFINED_ACLS
cloud.google.com/storage/docs/access-control/lists#predefined-acls
Attributes
directory[RW]
Public Instance Methods
body()
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 52 def body return attributes[:body] if attributes.key?(:body) file = collection.get(identity) attributes[:body] = if file file.attributes[:body] else "" end end
body=(new_body)
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 65 def body=(new_body) attributes[:body] = new_body end
copy(target_directory_key, target_file_key, options = {})
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 71 def copy(target_directory_key, target_file_key, options = {}) requires :directory, :key service.copy_object(directory.key, key, target_directory_key, target_file_key, options) target_directory = service.directories.new(:key => target_directory_key) target_directory.files.get(target_file_key) end
destroy()
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 78 def destroy requires :directory, :key service.delete_object(directory.key, key) true rescue ::Google::Apis::ClientError => e raise e unless e.status_code == 404 false end
predefined_acl=(new_predefined_acl)
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 45 def predefined_acl=(new_predefined_acl) unless VALID_PREDEFINED_ACLS.include?(new_predefined_acl) raise ArgumentError.new("acl must be one of [#{VALID_PREDEFINED_ACLS.join(', ')}]") end @predefined_acl = new_predefined_acl end
public=(new_public)
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 87 def public=(new_public) unless new_public.nil? if new_public @predefined_acl = "publicRead" else @predefined_acl = "projectPrivate" end end new_public end
public_url()
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 98 def public_url requires :directory, :key "https://storage.googleapis.com/#{directory.key}/#{key}" end
save()
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 112 def save requires :body, :directory, :key options = Hash[ FILE_INSERTABLE_FIELDS.map { |k| [k, attributes[k]] } .reject { |pair| pair[1].nil? } ] options[:predefined_acl] ||= @predefined_acl unless @uniform service.put_object(directory.key, key, body, **options) self.content_length = Fog::Storage.get_body_size(body) self.content_type ||= Fog::Storage.get_content_type(body) true end
uniform=(enable)
click to toggle source
# File lib/fog/storage/google_json/models/file.rb, line 41 def uniform=(enable) @uniform=enable end
url(expires, options = {})
click to toggle source
params : Eg: Time.now to integer value.
# File lib/fog/storage/google_json/models/file.rb, line 129 def url(expires, options = {}) requires :key collection.get_https_url(key, expires, options) end