mirror of https://github.com/apache/jclouds.git
JCLOUDS-1400: Honor Azure signed URL content type
This commit is contained in:
parent
7d40cedb20
commit
a35fa4a404
|
@ -34,6 +34,7 @@ import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.Uris;
|
import org.jclouds.http.Uris;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.net.HttpHeaders;
|
import com.google.common.net.HttpHeaders;
|
||||||
|
@ -74,7 +75,7 @@ public class AzureBlobRequestSigner implements BlobRequestSigner {
|
||||||
public HttpRequest signGetBlob(String container, String name, long timeInSeconds) {
|
public HttpRequest signGetBlob(String container, String name, long timeInSeconds) {
|
||||||
checkNotNull(container, "container");
|
checkNotNull(container, "container");
|
||||||
checkNotNull(name, "name");
|
checkNotNull(name, "name");
|
||||||
return sign("GET", container, name, null, timeInSeconds, null);
|
return sign("GET", container, name, null, timeInSeconds, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,13 +88,14 @@ public class AzureBlobRequestSigner implements BlobRequestSigner {
|
||||||
checkNotNull(container, "container");
|
checkNotNull(container, "container");
|
||||||
checkNotNull(blob, "blob");
|
checkNotNull(blob, "blob");
|
||||||
return sign("PUT", container, blob.getMetadata().getName(), null, timeInSeconds,
|
return sign("PUT", container, blob.getMetadata().getName(), null, timeInSeconds,
|
||||||
blob.getMetadata().getContentMetadata().getContentLength());
|
blob.getMetadata().getContentMetadata().getContentLength(),
|
||||||
|
blob.getMetadata().getContentMetadata().getContentType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpRequest signRemoveBlob(String container, String name) {
|
public HttpRequest signRemoveBlob(String container, String name) {
|
||||||
checkNotNull(container, "container");
|
checkNotNull(container, "container");
|
||||||
checkNotNull(name, "name");
|
checkNotNull(name, "name");
|
||||||
return sign("DELETE", container, name, null, DEFAULT_EXPIRY_SECONDS, null);
|
return sign("DELETE", container, name, null, DEFAULT_EXPIRY_SECONDS, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,10 +103,10 @@ public class AzureBlobRequestSigner implements BlobRequestSigner {
|
||||||
checkNotNull(container, "container");
|
checkNotNull(container, "container");
|
||||||
checkNotNull(name, "name");
|
checkNotNull(name, "name");
|
||||||
return sign("GET", container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")),
|
return sign("GET", container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")),
|
||||||
DEFAULT_EXPIRY_SECONDS, null);
|
DEFAULT_EXPIRY_SECONDS, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpRequest sign(String method, String container, String name, GetOptions options, long expires, Long contentLength) {
|
private HttpRequest sign(String method, String container, String name, @Nullable GetOptions options, long expires, @Nullable Long contentLength, @Nullable String contentType) {
|
||||||
checkNotNull(method, "method");
|
checkNotNull(method, "method");
|
||||||
checkNotNull(container, "container");
|
checkNotNull(container, "container");
|
||||||
checkNotNull(name, "name");
|
checkNotNull(name, "name");
|
||||||
|
@ -135,6 +137,10 @@ public class AzureBlobRequestSigner implements BlobRequestSigner {
|
||||||
request.replaceHeader(HttpHeaders.CONTENT_LENGTH, contentLength.toString());
|
request.replaceHeader(HttpHeaders.CONTENT_LENGTH, contentLength.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contentType != null) {
|
||||||
|
request.replaceHeader("x-ms-blob-content-type", contentType);
|
||||||
|
}
|
||||||
|
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
request.headers(options.buildRequestHeaders());
|
request.headers(options.buildRequestHeaders());
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class AzureBlobRequestSignerTest extends BaseRestAnnotationProcessingTest
|
||||||
request,
|
request,
|
||||||
"Content-Length: 2\n" +
|
"Content-Length: 2\n" +
|
||||||
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
|
"Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
|
||||||
|
"x-ms-blob-content-type: text/plain\n" +
|
||||||
"x-ms-blob-type: BlockBlob\n");
|
"x-ms-blob-type: BlockBlob\n");
|
||||||
|
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
|
|
Loading…
Reference in New Issue