Sha256: a3e9425ccdac6f864a3e594a057f9937f6c4e45d9b386fb4beda8aff44b845ca

Contents?: true

Size: 1009 Bytes

Versions: 6

Compression:

Stored size: 1009 Bytes

Contents

require 'fog/core/model'
require 'fog/aliyun/models/storage/files'

module Fog
  module Storage
    class Aliyun
      class Directory < Fog::Model
        identity :key

        def destroy
          requires :key
          prefix = key + '/'
          ret = service.list_objects(prefix: prefix)['Contents']

          if ret.nil?
            puts ' Not found: Direction not exist!'
            false
          elsif ret.size == 1
            service.delete_container(key)
            true
          else
            raise Fog::Storage::Aliyun::Error, ' Forbidden: Direction not empty!'
            false
          end
        end

        def files
          @files ||= begin
            Fog::Storage::Aliyun::Files.new(
              directory: self,
              service: service
            )
          end
        end

        def public_url
          nil
        end

        def save
          requires :key
          service.put_container(key)
          true
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
fog-aliyun-0.3.0 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.2.2 lib/fog/aliyun/models/storage/directory.rb
fog-xiaozhu-0.2.2 lib/fog/aliyun/models/storage/directory.rb
fog-xiaozhu-0.2.1 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.2.1 lib/fog/aliyun/models/storage/directory.rb
fog-aliyun-0.2.0 lib/fog/aliyun/models/storage/directory.rb