EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Error handeling with S3 storage class

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#15940
Posted: 02/28/2011 20:14:36
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

What are my options for error handling for various S3 storage class functions, such as: ReadObject, WriteObject, DeleteObject. It seems that they do generate exceptions (although it's not clear what exception class is used). But, for example, DeleteObject seems to "never fail" (i.e. deleting an object that does not exist does not throw an exception). More importantly, calling ReadObject on an object that does not exist does throw an exception ("Object does not exist" is returned in the E.Message), but I'd like to get a more "computer friendly" error code, specifically what was the HTTP result code (i.e. I might do something differently for a 404 than a 500).
#15945
Posted: 02/28/2011 20:33:45
by Ken Ivanov (EldoS Corp.)

Unfortunately, there is no way to access underlying HTTP return codes directly from the exceptions thrown by S3 storage component. However, you can check the ServerStatusCode and ServerReasonPhrase properties of the attached TElHTTPSClient object inside the except clause when the exception is thrown.

I have no idea why DeleteObject() does not throw an exception (according to the source code it can only mean that an S3 server returns a positive result even if the object does not exist). Will check this with the server though.
#15948
Posted: 02/28/2011 20:46:42
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

That's fine. Accessing the HTTP client properties indirectly gives me what I need.

Let me know what you find out on DeleteObject().

Tnx!
#15952
Posted: 03/01/2011 18:12:49
by Ken Ivanov (EldoS Corp.)

I've just tried calling DeleteObject() with fake bucket and object names, and got the "403 Forbidden" exception re-thrown by the TElAWSS3DataStorage. Could you please specify which exactly overload of DeleteObject() are you calling and what exactly values are you passing there?
#15953
Posted: 03/01/2011 19:08:26
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

I'm using the basic overload (bucket and key), but in my case, the bucket is real.
#15954
Posted: 03/01/2011 19:50:21
by Ken Ivanov (EldoS Corp.)

Hmm, I get the same results (403 exception) with a real bucket. Could you please handle the TElHTTPSClient.OnData event in order to catch the output of the AWS server?
#15984
Posted: 03/06/2011 17:22:37
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

I added a handler for OnData, but it never gets called (on any function, Delete included).
#15985
Posted: 03/06/2011 18:12:58
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

UPDATE: Correction, I do get OnData events for ReadObject and WriteObject calls, but nothing for DeleteObject.
#15991
Posted: 03/07/2011 02:53:00
by Ken Ivanov (EldoS Corp.)

Hmm, could you please also handle the OnReceivingHeaders event and check it's output?
#15997
Posted: 03/07/2011 12:31:30
by Eric Lenington (Standard support level)
Joined: 12/06/2010
Posts: 37

OK. Here's what I get:

UPLOAD
[OnHeaders]
HTTP/1.1 200 OK
x-amz-id-2: CwDHIw5WHPUcMIBgewP3yPcwjXKZDNImcaZXJR3RchOCrfcznKx7XCs2GdwBf918
x-amz-request-id: 287541DFFC59EF5E
Date: Mon, 07 Mar 2011 18:38:44 GMT
ETag: "fc243780acde27d31e98317a2701c312"
Content-Length: 0
Server: AmazonS3
AWS Headers:
x-amz-id-2: CwDHIw5WHPUcMIBgewP3yPcwjXKZDNImcaZXJR3RchOCrfcznKx7XCs2GdwBf918
x-amz-request-id: 287541DFFC59EF5E

DELETE
[OnHeaders]
HTTP/1.1 204 No Content
x-amz-id-2: DsQABY3iEjkI7fYZjRWWTAGg6CqmKkKcLJNZJuGrLe+th9TqmmN0Yg9drWzXXWuD
x-amz-request-id: 14982B757D58FC86
Date: Mon, 07 Mar 2011 18:38:59 GMT
Server: AmazonS3

DELETE
[OnHeaders]
HTTP/1.1 204 No Content
x-amz-id-2: VxAHR4cSORPpDe9bzu4UYXk5Mc+/WUpyOqSP8eV+sYizLf8kD4jLNJelIPgrK92N
x-amz-request-id: 90B078F3D07CAC61
Date: Mon, 07 Mar 2011 18:39:10 GMT
Server: AmazonS3


While doing this, I'm monitoring the target bucket on S3 using the Firefox S3 Plugin. After the upload, I verified that the file is there (and I can download it and see that its contents matches the original). After the first delete, I verified that the file is gone. It's very strange that both delete attempts return the same headers.
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 2729 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!