Can you change ACL on existing object?

Nov 26, 2008 at 2:41 PM
I see how to set the acl on an object to be uploaded, but is there something in the library to change the acl on an existing object or change the acl on the whole bucket?


Nov 30, 2008 at 5:17 PM

I've been looking at exactly this issue tonight and am puzzled why ThreeSharp does not support setting ACLs on existing objects (which is possible). I did work on this many months ago and made it work with a modification to ThreeSharp that looked something like this (note I change ThreeSharp into VB.NET before I work with it):

[code]

Public Function ACLSet(ByVal request As ACLSetRequest) As ACLSetResponse

Return Invoke(Of ACLSetResponse)(request)

End Function




 

Imports

 

Affirma.ThreeSharp.Model

 

Namespace

 

Affirma.ThreeSharp.Core.Model.SMTExtensions

Public Class ACLSetRequest

Inherits Request

Public Sub New(ByVal bucketName As String, ByVal key As String, ByVal CannedACL As String)

Me.Method = "PUT"

 

 

 

Me.QueryList.Add("acl", "")

Me.Headers.Add("x-amz-acl", CannedACL)

Me.BucketName = bucketName

Me.Key = key

End Sub

 

 

 

End Class

 

 

 

Public Class ACLSetResponse

Inherits Response

End Class

 

End

 

Namespace

 

 

[/code]

I'm trying to find a good way to implement this as a 'overlay' for ThreeSharp. Why? a) because I don't want to wait for TS to support this, I need it now. And b) I try to avoid making changes in TS so that it is easy to swap out the old version of TS when a new version is released.

Perhaps I'm missing something about how ThreeSharp supports setting ACLs...

_T

 

 

 


 

 

Nov 30, 2008 at 5:17 PM
Edited Nov 30, 2008 at 5:18 PM
[sorry, double post.]
Nov 30, 2008 at 7:01 PM
Ok, find below what I did to support setting of ACLs in ThreeSharp (three changes to Affirma.ThreeSharp).  I just tested it and found it functional in simple usage.  It would be nice if this were added to ThreeSharp so I don't have to add it manually each time a new version comes out and it should be useful to others.

 

1) Added ACLSet.cs file under Model\ with the following:

using System;

using System.IO;

using System.Xml.Serialization;

using System.Collections.Generic;

using System.Text;

using System.Security.Cryptography;

namespace Affirma.ThreeSharp.Model

{

public class ACLSetRequest : S3Request

{

public ACLSetRequest(string bucketName, string key, string CannedACL)

{

this.Method = "PUT";

this.QueryList.Add("acl", "");

this.Headers.Add("x-amz-acl", CannedACL);

this.BucketName = bucketName;

this.Key = key;

}

}

 

public class ACLSetResponse : S3Response

{

}

}


2) Added the following to ThreeSharp.cs

/// <summary>

/// </summary>

ACLSetResponse ACLSet(ACLSetRequest request);

 


3) Added the following to ThreeSharpQuery.cs

/// <summary>

///

/// </summary>

/// <param name="request"></param>

/// <returns></returns>

public ACLSetResponse ACLSet(ACLSetRequest request)

{

return Invoke<ACLSetResponse>(request);

}