Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-977

Wrong MD5 is being set to chunk on multipart upload

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.9.0
    • 1.9.1
    • jclouds-blobstore
    • None

    Description

      1. Construct a blob:

      Blob blob = blobStore.blobBuilder("blob-name")
      .payload(sourceBlob.getPayload().openStream())
      .contentLength(sourceBlob.getMetadata().getContentMetadata().getContentLength())
      .contentMD5(sourceBlob.getMetadata().getContentMetadata().getContentMD5AsHashCode())
      .build();
      

      2. Initiate upload:

      blobStore.putBlob("container-name", blob, PutOptions.Builder.multipart())
      

      3. Get an exception:

      org.jclouds.aws.AWSResponseException: request PUT https://xxxxxxx.s3.amazonaws.com/file.wmv?partNumber=1&uploadId=XPTNg5O8nmxp.PTmX9jbNJ.RFBOqozKRzAcso8O7oEqHkuadwRgW_aiyuCgShoVB316pToTcUDo_FKXXrEdH5A-- HTTP/1.1 failed with code 400, error: AWSError{requestId='01DA43F9D952570F', requestToken='W1uccq2LxM3BMBeNhgz1aYLglTtOhqBtJm5tvcaAzhPZCZtegnFN96oK4JzBEy3LqKP/sBy4cSs=', code='BadDigest', message='The Content-MD5 you specified did not match what we received.', context='{CalculatedDigest=4MVdqDCufuGS2c4clr9SPg==, ExpectedDigest=e8s07WDHzryJUU7NYyE5GA==, HostId=W1uccq2LxM3BMBeNhgz1aYLglTtOhqBtJm5tvcaAzhPZCZtegnFN96oK4JzBEy3LqKP/sBy4cSs=}'}
      	at org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent.handleError(ParseAWSErrorFromXmlContent.java:75)
      	at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:65)
      	at org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:132)
      	at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:101)
      	at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:90)
      	at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
      	at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
      	at org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(DelegatesToInvocationFunction.java:156)
      	at org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(DelegatesToInvocationFunction.java:123)
      	at com.sun.proxy.$Proxy48.uploadPart(Unknown Source)
      	at org.jclouds.s3.blobstore.strategy.internal.SequentialMultipartUploadStrategy.prepareUploadPart(SequentialMultipartUploadStrategy.java:111)
      	at org.jclouds.s3.blobstore.strategy.internal.SequentialMultipartUploadStrategy.execute(SequentialMultipartUploadStrategy.java:93)
      	at org.jclouds.aws.s3.blobstore.AWSS3BlobStore.putBlob(AWSS3BlobStore.java:87)
      

      Seems that the error is caused by org.jclouds.io.ContentMetadataBuilder.contentMD5(HashCode) method, which ignores any null hashcode, and the following code in org.jclouds.io.internal.BasePayloadSlicer.InputStreamPayloadIterator.createPayload(byte[]) can't replace the checksum with null:

      ContentMetadata cm = metaData.toBuilder().contentLength((long)content.length).contentMD5((HashCode) null).build();
      payload.setContentMetadata(BaseMutableContentMetadata.fromContentMetadata(cm));
      

      Attachments

        Activity

          People

            khc Ka-Hing Cheung
            novokhatsky Roman Novokhatsky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: