jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Orlov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JCLOUDS-1400) GCS's presigned url requires blank Content-Type
Date Thu, 05 Apr 2018 06:33:00 GMT
Ivan Orlov created JCLOUDS-1400:
-----------------------------------

             Summary: GCS's presigned url requires blank Content-Type
                 Key: JCLOUDS-1400
                 URL: https://issues.apache.org/jira/browse/JCLOUDS-1400
             Project: jclouds
          Issue Type: Bug
          Components: jclouds-blobstore
    Affects Versions: 2.1.0
            Reporter: Ivan Orlov


I am trying to signPutBlob for google cloud storage.

1)
{code:java}
BlobStoreContext context = ContextBuilder.newBuilder("google-cloud-storage")
    .credentials(GOOGLE_ACCESS_KEY, GOOGLE_SECRET_KEY)
    .buildView(BlobStoreContext.class);

BlobStore blobStore = context.getBlobStore();

Blob blob = blobStore
    .blobBuilder("3.png")
    .forSigning()
    .contentLength(20493)
    .contentType(MediaType.PNG)   // setting contentType
    .build();

HttpRequest httpRequest = context
    .getSigner()
    .signPutBlob("cs-29337eeb-27c1-4dbc-805c-f01ba1744eb1", blob, 3600);
{code}

2)
{code:java}
PUT http://storage.googleapis.com/cs-29337eeb-27c1-4dbc-805c-f01ba1744eb1/3.png?Expires=1523454042&GoogleAccessId=access-s3%40storage-app-199609.iam.gserviceaccount.com&Signature=Aoam8qw0NYIDGDKBW4PpJXPklchTndaFwk4syrw0/K4c50hrDZFKG/oARWn1nSEKqRZlBuh2BBQtRSRNNH7Ol6Qhybo%2BX1hst7PxkaUue2iQwR%2B/t8p4izl%2BTGEJ99x2KdYsZb3Q7CmJvWkPlJ27KUGdVyJf/tTDGYwtE2uekXFxMu9r355N5RsBWBftW8kKnOaZBFsjO/q25bYs%2BAa/gQ01HfoQdDSPCYZ5QZST5G1vXYLuRcxYs3Hb33N3s5hq07/Nnopoai7CtrPKR1iSm766fzMaqZaSihXAQzCge5F25esML0kUkKvK%2BQBdFESD433Y1%2B33vg%2BZ9xvVlV3UlA%3D%3D
HTTP/1.1

Headers:
Content-Type: image/png{code}
 

Response:
{code:java}
<?xml version='1.0' encoding='UTF-8'?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided.
Check your Google secret key and signing method.</Message>
<StringToSign>PUT

image/png
1523454042
/cs-29337eeb-27c1-4dbc-805c-f01ba1744eb1/3.png</StringToSign>
</Error>
{code}
 

3) With no passed content-type it becomes text/plain
{code:java}
<?xml version='1.0' encoding='UTF-8'?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided.
Check your Google secret key and signing method.</Message>
<StringToSign>PUT

text/plain
1523454042
/cs-29337eeb-27c1-4dbc-805c-f01ba1744eb1/3.png</StringToSign>
</Error>
{code}
 

 

4) And with passed _Content-Type: ""_ it's okay.

 

5) GoogleCloudStorageBlobRequestSigner.java
{code:java}
@Override
public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) {
    return sign("PUT", container, blob.getMetadata().getName(), GetOptions.NONE, timestamp.get()
+ timeInSeconds, null);
}

private HttpRequest sign(String method, String container, String name, GetOptions options,
long expires, String contentType) {
    checkNotNull(container, "container");
    checkNotNull(name, "name");
    ...
}
{code}
Why is the last parameter "contentType" always null? We could read it from the blob, from
{code:java}
blob.getMetadata().getContentMetadata().getContentType();{code}
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message