Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get an object's storage class ? #354

Open
jdkealy opened this issue Dec 12, 2017 · 6 comments
Open

how to get an object's storage class ? #354

jdkealy opened this issue Dec 12, 2017 · 6 comments

Comments

@jdkealy
Copy link

jdkealy commented Dec 12, 2017

I see in the Java SDK you'd get an object's storage class using the following, how would I do it using amazonica?

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/model/StorageClass.html

@mcohen01
Copy link
Owner

maybe (:storage-class (s3/get-object-metadata "bucket" "key"))

@jdkealy
Copy link
Author

jdkealy commented Dec 12, 2017

that returns nil

@mcohen01
Copy link
Owner


    getStorageClass

    public String getStorageClass()

    Returns:
        The storage class of the object. Returns null if the object is in STANDARD storage. See StorageClass for possible values

@jdkealy
Copy link
Author

jdkealy commented Dec 12, 2017

The key I'm looking at though is in Glacier.

This is what get-object-metadata returns

{:content-disposition nil, :expiration-time-rule-id nil, :user-metadata nil, :instance-length 1855830, :version-id nil, :server-side-encryption nil, :server-side-encryption-aws-kms-key-id nil, :etag "49a370b2166390078800941d9ccb39c3", :last-modified #object[org.joda.time.DateTime 0x78b85044 "2017-12-11T16:40:39.000-05:00"], :cache-control nil, :http-expires-date nil, :content-length 1855830, :content-type "image/gif", :restore-expiration-time nil, :content-encoding nil, :expiration-time nil, :content-md5 nil, :ongoing-restore nil}

get-object returns this error indicating it is not the standard storage class

   The operation is not valid for the object's storage class (Service:
   Amazon S3; Status Code: 403; Error Code: InvalidObjectState; Request
   ID: 6C4A2F86F24BE092)

@mcohen01
Copy link
Owner

i'm guessing maybe the storage class comes in as a header that we're not parsing

@mcohen01
Copy link
Owner

dumping the headers shows it's in the response headers. not sure why it isn't being populated in the ObjectMetadata. you may want to try asking on the sdk project.

user=> (s3/get-object-metadata "amazonica" "foobar")
{"x-amz-content-sha256" "UNSIGNED-PAYLOAD",
 "Authorization"
 "AWS4-HMAC-SHA256 Credential=AKIAIMMME3975ZTWIOIW/20171010/us-east-1/s3/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-retry;content-type;host;user-agent;x-amz-content-sha256;x-amz-date, Signature=3574b7b10d2335441f18c9272b94d102f6d65dba07b9a73976328b3e86fc8c9d2",
 "X-Amz-Date" "20171212T230401Z",
 "User-Agent"
 "aws-sdk-java/1.11.237 Mac_OS_X/10.11.6 Java_HotSpot(TM)_64-Bit_Server_VM/25.151-b12 java/1.8.0_151 clojure/1.8.0",
 "amz-sdk-invocation-id" "981bb771-e73d-df83-1643-0244b5675f96",
 "Host" "amazonica.s3.amazonaws.com",
 "amz-sdk-retry" "0/0/500",
 "Content-Type" "application/octet-stream"}
{"Last-Modified" "Tue, 12 Dec 2017 19:43:44 GMT",
 "Date" "Tue, 12 Dec 2017 23:04:03 GMT",
 "ETag" "\"258622b1688250cb619f3c9ccaefb7eb\"",
 "Accept-Ranges" "bytes",
 "Content-Length" "4",
 "Server" "AmazonS3",
 "Content-Type" "application/octet-stream",
 "x-amz-request-id" "D84EC7F676B6C09A",
 "x-amz-id-2"
 "wMlCOWRF+WzTh9g22W3EVrDKq62Bt2aZHSzfmBO+ZFnUASWfkW7Lq/DEOAWM/xR5nQhWFM3OcYY=",
 "x-amz-storage-class" "REDUCED_REDUNDANCY"}
{:content-disposition nil, :expiration-time-rule-id nil, :user-metadata nil, :instance-length 4, :version-id nil, :server-side-encryption nil, :server-side-encryption-aws-kms-key-id nil, :etag "258622b1688250cb619f3c9ccaefb7eb", :last-modified #object[org.joda.time.DateTime 0x5949500c "2017-12-12T11:43:44.000-08:00"], :cache-control nil, :http-expires-date nil, :content-length 4, :content-type "application/octet-stream", :restore-expiration-time nil, :content-encoding nil, :expiration-time nil, :content-md5 nil, :ongoing-restore nil}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants