Sha256: d3b329d44b059f7aa90bf61ed37690f5ad094dcdaf5495dab71873a2d1928e92
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
class Fog::Storage::Backblaze::File < Fog::Model identity :file_name, aliases: %w{fileName key name} attribute :content_length, aliases: 'contentLength' attribute :content_type, aliases: 'contentType' attribute :file_id, aliases: 'fileId' attribute :file_info, aliases: 'fileInfo' attribute :upload_timestamp, aliases: 'uploadTimestamp' attr_accessor :directory alias_method :name, :file_name # TODO: read content from cloud on demand def body attributes[:body] #||= file_id && (file = collection.get(identity)) ? file.body : "" end def body=(new_body) attributes[:body] = new_body end alias_method :key, :file_name alias_method :key=, :file_name= def save(options = {}) requires :body, :directory, :key options[:content_type] = content_type if content_type data = service.put_object(directory.key, key, body, options) merge_attributes(data.headers.reject { |key, _value| %w(contentLength contentType).include?(key) }) self.content_length = Fog::Storage.get_body_size(body) self.content_type ||= Fog::Storage.get_content_type(body) true end def destroy requires :key response = service.delete_object(directory.key, key) return response.status < 400 #rescue Fog::Errors::NotFound # false end def public_url requires :directory, :key service.get_object_url(directory.key, key) end # TODO #def url(expires) # requires :key # collection.get_https_url(key, expires) #end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fog-backblaze-0.2.0 | lib/fog/storage/backblaze/models/file.rb |
fog-backblaze-0.1.2 | lib/fog/storage/backblaze/models/file.rb |