Sha256: 3fc24d7cba07545e2991fa6a0141f75b7b2fd567acc2f63ce16d1544775dda62
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require 'fog/core/model' require 'fog/aliyun/models/storage/files' module Fog module Storage class Aliyun class Directory < Fog::Model identity :key, :aliases => ['Key', 'Name', 'name'] def destroy requires :key prefix = key + '/' ret = service.list_objects(prefix: prefix)['Contents'] if ret.nil? 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 # Checking whether the key is a bucket and meet the multi-bucket scenario. # If the key is a existing bucket, return it directly. key = key.chomp('/') if !key.nil? && key != '' && key != '.' && !(key.include? '/') data = service.get_bucket(key) if data.class == Hash && data.key?('Code') && !data['Code'].nil? && !data['Code'].empty? service.put_container(key) end end true end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fog-aliyun-0.3.10 | lib/fog/aliyun/models/storage/directory.rb |
fog-aliyun-0.3.9 | lib/fog/aliyun/models/storage/directory.rb |