Пример #1
0
        public async Task <OperationResult> CreateBlob(byte[] payload, string key)
        {
            bool exist = await ExistBlob(key);

            if (exist)
            {
                return(new OperationResult(false, "Object already exist", HttpStatusCode.BadRequest));
            }
            string endpoint = $"https://{_region}.digitaloceanspaces.com/{_key}/{key}";
            var    resp     = await _client.SendRequest(HttpMethod.Put, endpoint, payload);


            bool isPub = await _bucketClient.IsBucketPublic(_key);

            ReadAccess access = isPub ? ReadAccess.Public : ReadAccess.Private;

            var acl = await _bucketClient.SetBlobACL(new Uri(endpoint), access, 10);

            if (!acl.Success)
            {
                return(acl);
            }

            return(resp.Success ? resp.AppendUri(endpoint) : resp);
        }
        public async Task <OperationResult> CreateBucket(string key)
        {
            string endpoint = $"https://{_region}.digitaloceanspaces.com/{key}";

            return(await _client.SendRequest(HttpMethod.Put, endpoint));
        }