Sha256: 4f7467f3e3e72942dd09dfb0f258a5be1e5466c885bf9e6309e5ffc46bf309e6

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'carrierwave'
require "tencent_cos_sdk"

module CarrierWave
    module Storage
        class TencentCos < Abstract
            # Create and save a file instance to your engine.
            def store!(file)
                f = CarrierWave::Storage::TencentCos::File.new(uploader.store_path)
                f.store(file)
                f
            end

            # Load and return a file instance from your engine.
            def retrieve!(identifier)
                CarrierWave::Storage::TencentCos::File.new(uploader.store_path(identifier))
            end

            # Subclass or duck-type CarrierWave::SanitizedFile
            # responsible for storing the file to your engine.
            class File
                attr_reader :path

                # Initialize as required.
                def initialize(path)
                    @path = path
                end

                def store(new_file)
                    TencentCosSdk.put @path, file: new_file.path
                end

                def url
                    TencentCosSdk.url @path
                end

                def delete
                    TencentCosSdk.delete @path
                end
            end # File
        end # TencentCos
    end # Storage
end # CarrierWave

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
carrierwave-tencent_cos-0.1.3 lib/carrierwave/storage/tencent_cos.rb
carrierwave-tencent_cos-0.1.1 lib/carrierwave/storage/tencent_cos.rb
carrierwave-tencent_cos-0.1.0 lib/carrierwave/storage/tencent_cos.rb