Пример #1
0
        private StorageClient CreateClient(string bucketName)
        {
            //确认OSS对象存储配置
            var configuration = this.EnsureConfiguration();

            //获取指定名称的存储器配置项
            configuration.Buckets.TryGet(bucketName, out var bucket);

            var region      = this.GetRegion(bucket);
            var center      = StorageServiceCenter.GetInstance(region, Aliyun.Configuration.Instance.IsInternal);
            var certificate = this.GetCertificate(bucket);

            return(new StorageClient(center, certificate));
        }
Пример #2
0
        public string GetUrl(Zongsoft.IO.Path path)
        {
            if (path == null || path.Segments.Length == 0)
            {
                return(null);
            }

            //确认OSS对象存储配置
            var configuration = this.EnsureConfiguration();

            //获取当前路径对应的存储器配置项,注:BucketName即为路径中的第一节
            configuration.Buckets.TryGet(path.Segments[0], out var bucket);

            //获取当前路径对应的服务区域
            var region = this.GetRegion(bucket);

            return(StorageServiceCenter.GetInstance(region, false).GetRequestUrl(path.FullPath));
        }