Mono Support AmazonS3FileSystemContentProvider: Delete file issue  

Viewed 16984 time(s), 6 post(s), 5/18/2015 1:15:16 PM - by nasman
5/18/2015 1:15:16 PM
845 Reputation 93 Total posts

Hi 
I am testing the AmazonS3FileSystemContentProvider.  StoreFile and GetFile methods are working fine.  There is an issue with the DeleteFile method. I am getting a following error message when I call the DeleteFile Method. I think there is an issue with the threesharp library. Its translating the bucket URL differently. It should use https://BucketName.s3.amazonaws.com/Upload/user/john/user-drive/vP27ROWJm06cceX7bSwyYw-Blank_CV.docx  instead of  https://s3.amazonaws.com/BucketName/Upload/user/john/user-drive/vP27ROWJm06cceX7bSwyYw-Blank_CV.docx. Can you please check for me?

Many Thanks




Fiddler Request: 

DELETE https://s3.amazonaws.com/BucketName/Upload/user/john/user-drive/vP27ROWJm06cceX7bSwyYw-Blank_CV.docx HTTP/1.1
User-Agent: Amazon S3 CSharp Library
x-amz-date: Mon, 18 May 2015 13:09:41 GMT
Authorization: AWS AKIAJ7U7V6XTOHJXZ7WA:+LdN46Z8sdfdsi5hB234unpLIfRl6aBs=
Host: s3.amazonaws.com
Content-Length: 0


Fiddler Response: 

HTTP/1.1 301 Moved Permanently
x-amz-request-id: 1F980978AB724F96
x-amz-id-2: GJTbdz+kWXnspwGvkx5MiOi3Wr79PwhAGGH1B5OpKybJI7/f7Fz4ECIfnZ3+YzDmvGZsXTeLXEM=
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Mon, 18 May 2015 13:09:42 GMT
Server: AmazonS3

1bd
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><Bucket>BucketName</Bucket><Endpoint>BucketName.s3.amazonaws.com</Endpoint><RequestId>1F980978AB724F96</RequestId><HostId>GJTbdz+kWXnspwGvkx5MiOi3Wr79PwhAGGH1B5OpKybJI7/f7Fz4ECIfnZ3+YzDmvGZsXTeLXEM=</HostId></Error>
0

 

1
5/18/2015 3:01:57 PM
1384 Reputation 152 Total posts

Hi nasman,

Do you have "urlFormat" specified in web.config?

<add name="AmazonS3FileSystemContentProvider" type="MonoSoftware.MonoX.FileSystem.AmazonS3FileSystemContentProvider, MonoX" bucketLocation="us" accessKeyId="xxxxxxxxx" secretAccessKey="xxxxxxxxxx" urlFormat="{0}.s3.amazonaws.com" />

MonoX version?

Regards,
Igor

2
5/18/2015 3:38:25 PM
845 Reputation 93 Total posts

HIi idrazic,

All the AmazonS3FileSystemContentProvider settings are fine that's why StoreFile is working. We have purchased the source code and done some customisation but didn't change anything in the  FileSystemContentProviders .  Monox version is 4.7.40.3493.   

Thanks

3
5/19/2015 8:00:49 AM
1384 Reputation 152 Total posts

It looks like our AmazonS3FileSystemContentProvider will need an update.
My assumption is that ThreeSharpWrapper uses a calling format that is not supported any more.
I haven't tested this yet, but it looks like all methods that user ThreeSharpWrapper will need to be modified to use Object[Add|Copy|Delete]Request 
Can you test if it will work with this code (replace):

private string DeleteObject(string path)
{
    try
    {
        using (ObjectDeleteRequest request = new ObjectDeleteRequest(GetBucketNameFromPath(path), GetEncodedPath(path)))
        {
            using (ObjectDeleteResponse response = this.service.ObjectDelete(request))
            {
                return response.StatusCode == System.Net.HttpStatusCode.OK ? string.Empty :
                    response.StreamResponseToString();
            }
        }
    }
    catch (Exception ex)
    {
        return ex.Message;
    }
}

4
5/19/2015 8:38:37 AM
845 Reputation 93 Total posts

 Yes, It's working. I have checked the ThreeSharp library page(http://threesharp.codeplex.com/). They are recommending that we should  use AWS SDK instead of the ThreeSharp library. They are no longer maintaining the ThreeSharp library.  Is it possible for you that you can update AmazonS3FileSystemContentProvider using AWS SDK? 
 

Many Thanks

5
5/19/2015 9:42:28 AM
1384 Reputation 152 Total posts

Thank you for testing.

Provider will certainly need to be updated to overcome the endpoint issues.
I don't know if we will upgrade to AWS SDK right away.

Regards,
Igor

6
This is a demo site for MonoX. Please visit Mono Software for more info.