Revision ff26eb71 trunk/Pithos.Network/CloudFilesClient.cs
b/trunk/Pithos.Network/CloudFilesClient.cs | ||
---|---|---|
266 | 266 |
} |
267 | 267 |
} |
268 | 268 |
|
269 |
public void SetTags(ObjectInfo target,IDictionary<string,string> tags) |
|
270 |
{ |
|
271 |
if (String.IsNullOrWhiteSpace(Token)) |
|
272 |
throw new InvalidOperationException("The Token is not set"); |
|
273 |
if (StorageUrl == null) |
|
274 |
throw new InvalidOperationException("The StorageUrl is not set"); |
|
275 |
if (target == null) |
|
276 |
throw new ArgumentNullException("target"); |
|
277 |
Contract.EndContractBlock(); |
|
278 |
|
|
279 |
using (log4net.ThreadContext.Stacks["Share"].Push("Share Object")) |
|
280 |
{ |
|
281 |
if (Log.IsDebugEnabled) Log.DebugFormat("START"); |
|
282 |
|
|
283 |
using (var client = new RestClient(_baseClient)) |
|
284 |
{ |
|
285 |
|
|
286 |
client.BaseAddress = GetAccountUrl(target.Account); |
|
287 |
|
|
288 |
client.Parameters.Clear(); |
|
289 |
client.Parameters.Add("update", ""); |
|
290 |
|
|
291 |
foreach (var tag in tags) |
|
292 |
{ |
|
293 |
var headerTag = String.Format("X-Object-Meta-{0}", tag.Key); |
|
294 |
client.Headers.Add(headerTag, tag.Value); |
|
295 |
} |
|
296 |
|
|
297 |
var content = client.DownloadStringWithRetry(target.Container, 3); |
|
298 |
|
|
299 |
|
|
300 |
client.AssertStatusOK("SetTags failed"); |
|
301 |
//If the status is NOT ACCEPTED we have a problem |
|
302 |
if (client.StatusCode != HttpStatusCode.Accepted) |
|
303 |
{ |
|
304 |
Log.Error("Failed to set tags"); |
|
305 |
throw new Exception("Failed to set tags"); |
|
306 |
} |
|
307 |
|
|
308 |
if (Log.IsDebugEnabled) Log.DebugFormat("END"); |
|
309 |
} |
|
310 |
} |
|
311 |
|
|
312 |
|
|
313 |
} |
|
314 |
|
|
269 | 315 |
public void ShareObject(string account, string container, string objectName, string shareTo, bool read, bool write) |
270 | 316 |
{ |
271 | 317 |
if (String.IsNullOrWhiteSpace(Token)) |
Also available in: Unified diff