[ 
https://issues.apache.org/jira/browse/JCLOUDS-391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14013595#comment-14013595
 ] 

Klaus Müller commented on JCLOUDS-391:
--------------------------------------

Hi Andrew,
this issue is still open and unresolved.
I did some more tests with user defined meta data. 
In case of multipart upload user defined meta data were not set, because 
BlobMetaDataToBlobProperties is missing.
No MetaData were set, only these from Blob.payload.contentMetadata:

AzureBlobBlockUploadStrategy.java:

 @Override
   public String execute(String container, Blob blob) {
      String blobName = blob.getMetadata().getName();
      Payload payload = blob.getPayload();
      Long length = payload.getContentMetadata().getContentLength();
      checkNotNull(length,
            "please invoke 
payload.getContentMetadata().setContentLength(length) prior to azure block 
upload");
      checkArgument(length <= (MAX_NUMBER_OF_BLOCKS * MAX_BLOCK_SIZE));
      long offset = 0L;
      List<String> blockIds = Lists.newArrayList();
      long bytesWritten = 0;
      while (offset < length) {
         long chunkSize = MAX_BLOCK_SIZE;
         if (length - offset < MAX_BLOCK_SIZE) {
            chunkSize = length % MAX_BLOCK_SIZE;
         }
         bytesWritten += chunkSize;
         Payload block = slicer.slice(payload, offset, chunkSize);
         offset += MultipartUploadStrategy.MAX_BLOCK_SIZE;
         String blockName = blobName + "-" + offset + "-" + new 
SecureRandom().nextInt();
         byte blockIdBytes[] = 
Hashing.md5().hashBytes(blockName.getBytes()).asBytes();
         String blockId = BaseEncoding.base64().encode(blockIdBytes);
         blockIds.add(blockId);
         client.putBlock(container, blobName, blockId, block);
      }
      checkState(bytesWritten == length, "Wrote %s bytes, but we wanted to 
write %s bytes", bytesWritten, length);
      return client.putBlockList(container, blobName, blockIds);
   }

User defined meta data from Blob.metadata.userMetadata were not copied.

You have an idea how to solve this problem? We have to set user defined meta 
data for Azure blobs, in other case we can't use JClouds.

Best Regards
Klaus


> can't set user-defined metadata for Azure with multipart blobs
> --------------------------------------------------------------
>
>                 Key: JCLOUDS-391
>                 URL: https://issues.apache.org/jira/browse/JCLOUDS-391
>             Project: jclouds
>          Issue Type: Bug
>          Components: jclouds-blobstore
>    Affects Versions: 1.6.2
>         Environment: Windows 7, Azure and S3
>            Reporter: Klaus Müller
>            Priority: Critical
>
> Try to set user defined meta data for Azure blob storage. No error setting 
> meta data, but when I try to read them, they were not stored for the given 
> blob.
> my code (small part of it):
>    ...
>    BlobStore blobStore = Context.getBlobStore();
>    BlobBuilder builder = blobStore.blobBuilder("blob001");
>    PayloadBlobBuilder  payload = builder.payload(data);       // data is 
> InputStream
>    payload.contentLength(datalen);
>    Blob blob = payload.build();
>    Map<String, String> keyValueMap = new HashMap<String, String>();
>    keyValueMap.put("testmeta","12345");
>    blob.getMetadata().setUserMetadata(keyValueMap);
>    blobStore.putBlob("container001", blob, multipart() );
> ...
> For S3 it works.
> Is this a known problem with Azure, or something wrong with my code?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to