locked
Upload a file to HealthVault, not compatible with the old version? RRS feed

  • Question

  • Old version: 1 . 0 . 2 1 4 5 . 4 5 0 4
    New version: 1 . 0 . 2 1 9 3 . 4 7 1 2

    1.get content from file:
        byte[] bytes=FileUpload.FileBytes;
        string contents=Convert.ToBase64String(bytes);

    2.add the same  file content to health vault in old and new SDK
    for old version: File.OtherData.Data=contents;
    for new version:    Blob.WriteInline(bytes);
    then there are two items there, one is created in old sdk, the other is created in new sdk.

    3. read file content from health vault in old sdk
       Everything  is ok
       you get the right content from both items created in new sdk and old sdk

    4. read file content from healthvault in new sdk
       you can get the right file content from the item which you created in new sdk,
       byte[] bytes=File.Content;
       but you can not get the right file content from the item which you created in old sdk
       string contents=File.OtherData.Data
      
    problem: contents != Convert.ToBase64String(bytes);

    Is there any idea  for this problem?

    Eric Zuo

      
    Monday, January 11, 2010 7:12 PM

Answers

  • Hi Eric,
      I suspect your issue is happening because in the step where you use the old SDK to set the bytes, the Content is set to the base64 converted string, however the ContentEncoding is left unset. If it is set to "base64", Healthvault platform would understand the encoding of the incoming bytes and decode them correctly. In this case since it is unaware of the encoding used, it does not decode the bytes, but leaves them as is. Hence in the two sets of bytes you get, I guess the old SDK bytes would be the bytes of the base64 string as opposed to the raw contents of the file.
    I would suggest that the ContentEncoding be set to base64 in the old SDK case. Please let us know if you see the issue, with the content encoding set correctly in the old SDK case.  
    • Marked as answer by Eric0622 Tuesday, January 12, 2010 11:36 PM
    Tuesday, January 12, 2010 9:03 PM

All replies

  • Hi Eric,

    I have tried with the steps you provided, but the issue is not reproducible.

    You can use byte[] bytes = file.Content and can get the file contents which are uploaded using both old sdk and new sdk.
    In the new sdk, you cannot use the otherdata property.


    -Mahesh
    Monday, January 11, 2010 9:51 PM
  • Hi Mahesh,
    Sorry for my mistake,

    Old version: 1 . 0 . 2 1 4 5 . 4 5 0 4
    New version: 1 . 0 . 2 1 9 3 . 4 7 1 2

    1.get content from file:
        byte[] bytesWrite=FileUpload.FileBytes;
        string contentsWrite=Convert.ToBase64String(bytesWrite);

    2.add tow items with the same  file content to health vault in old and new SDK
    item1: in old version: File.OtherData.Data=contentsWrite;
    item2: in new version:    Blob.WriteInline(bytesWrite);
    then there are two items there, one is created in old sdk, the other is created in new sdk.

    3. read file content from health vault in old sdk(get that two items which we created before)
       Everything  is ok
       string contentsRead=File.OtherData.Data
       you will find contentsRead=contentWrite for both item. 
         

    4. read file content from healthvault in new sdk(get that two items which we created before)
       now try to get the file content from these two items in new sdk,
       byte[] bytesReadItem1=FileItem1.Content;
       byte[] bytesReadItem2=FileItem2.Content;
       You will find bytesReadItem1 != bytesReadItem2
       Actually they should be the same, because they are from the same document.


    Eric Zuo

    Monday, January 11, 2010 10:49 PM
  • I can reproduce the issue you are seeing above.
    I am contacting the technical team now and will let you know soon.
    -Mahesh
    Tuesday, January 12, 2010 7:46 PM
  • Hi Eric,
      I suspect your issue is happening because in the step where you use the old SDK to set the bytes, the Content is set to the base64 converted string, however the ContentEncoding is left unset. If it is set to "base64", Healthvault platform would understand the encoding of the incoming bytes and decode them correctly. In this case since it is unaware of the encoding used, it does not decode the bytes, but leaves them as is. Hence in the two sets of bytes you get, I guess the old SDK bytes would be the bytes of the base64 string as opposed to the raw contents of the file.
    I would suggest that the ContentEncoding be set to base64 in the old SDK case. Please let us know if you see the issue, with the content encoding set correctly in the old SDK case.  
    • Marked as answer by Eric0622 Tuesday, January 12, 2010 11:36 PM
    Tuesday, January 12, 2010 9:03 PM