Sha256: c54edce065c00f08002d8b4a9644e9b0d34e7ee9abdb361c5831eff2351fb28c

Contents?: true

Size: 944 Bytes

Versions: 1

Compression:

Stored size: 944 Bytes

Contents

module CarrierWave
  module Storage
    class UcloudFile < CarrierWave::SanitizedFile
      attr_reader :path, :bucket

      def initialize(uploader, base, path)
        @uploader = uploader
        @path     = path
        @base     = base
        @bucket   = ::CarrierWave::Ucloud::Bucket.new(uploader)
      end

      def read
        response = bucket.get(path)
        @headers = response.headers.deep_transform_keys { |k| k.underscore.to_sym rescue key }
        response.body
      end

      def delete
        bucket.delete(path)
      end

      def url(opts = {})
        bucket.url(path, opts)
      end

      def store(file, headers = {})
        bucket.put(path, file, headers)
      end

      def content_type
        headers[:content_type]
      end

      def content_type=(new_content_type)
        headers[:content_type] = new_content_type
      end

      def headers
        @headers ||= {}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrierwave_ucloud-0.1.2 lib/carrierwave/storage/ucloud_file.rb