Skip to content

Commit

Permalink
fix batch rs host
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Dec 7, 2023
1 parent 34080d0 commit d205168
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/Qiniu/Storage/BucketManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,36 @@ private BatchResult Batch(string batchOps)
{
BatchResult result = new BatchResult();

string bucket = "";
foreach (string op in batchOps.Split('&'))
{
string[] segments = op.Split('/');
if (segments.Length < 3)
{
continue;
}

string entry = Encoding.UTF8.GetString(Base64.UrlsafeBase64Decode(segments[2]));
bucket = entry.Split(':')[0];

if (bucket.Length > 0)
{
break;
}
}

if (bucket.Length == 0)
{
result.Code = (int)HttpCode.INVALID_ARGUMENT;
result.RefCode = (int)HttpCode.INVALID_ARGUMENT;
result.Text = "{\"error\":\"bucket is Empty\"}";
result.RefText = "bucket is Empty";
return result;
}

try
{
string scheme = this.config.UseHttps ? "https://" : "http://";
string rsHost = string.Format("{0}{1}", scheme, Config.DefaultRsHost);
string batchUrl = rsHost + "/batch";
string batchUrl = string.Format("{0}/batch", this.config.RsHost(this.mac.AccessKey, bucket));

HttpResult hr = httpManager.PostForm(batchUrl, null, batchOps, auth);
result.Shadow(hr);
Expand Down

0 comments on commit d205168

Please sign in to comment.