locked
SHARE TARGET PROBLEM WHEN SHARING storageItems RRS feed

  • Question

  • WHY i can get even the correct name of the file (fileName) even th full path BUT createObjectURL DOES NOT WORK when i get StandardDataFormats.storageItems?
    if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.storageItems)) {
                shareOperation.data.getStorageItemsAsync().done(function (storageItems) {

                    fileName = storageItems.getAt(0).name;
                    var storageItem = storageItems.getAt(0);
                    image = document.getElementById("imageHolder");
                    image.src = URL.createObjectURL(storageItem);

    AND IT WORKS WHEN IT'S JUST A .StandardDataFormats.bitmap:

    if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.bitmap)) {
                shareOperation.data.getBitmapAsync().done(function (bitmapStreamReference) {
                    bitmapStreamReference.openReadAsync().done(function (bitmapStream) {

        
    Friday, February 28, 2014 6:15 AM

Answers

  • A repro would help here. I took the Share source app sample and the Share target app sample as a test. The source app sample can select multiple files in scenario X for this purpose.

    I modified target.html in the Target sample to include this line:

    <div><img id="testImage1" src="#" style="height: 300px; width: 300px" /></div>
    And in target.js, I located the place where it looks for the storage items and added the last two lines:
    if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.storageItems)) {
        shareOperation.data.getStorageItemsAsync().done(function (storageItems) {
            var fileList = "";
            var u = URL.createObjectURL(storageItems.getAt(0), { oneTimeOnly: true });
            document.getElementById("testImage1").src = u;
    
    And the first image shows just fine when I share from the source sample. What are you using as a share source to test your code? It sounds like the StorageFile objects in the data package aren't actually correct.

    Monday, March 3, 2014 11:23 PM

All replies

  • Can you provide a sample repro of your problem?

    That way it will be easier to understand what is happening. You can use SkyDrive/OneDrive to share your repro. Here's how you can share files using OneDrive: http://windows.microsoft.com/en-us/onedrive/share-file-folder


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Saturday, March 1, 2014 1:40 AM
    Moderator
  • Anyone else can help?
    the CODE is right there.. there's nothing more involved.. it's very simple.. 

    Kraig Brockschmidt ? Do you have any idea why this is happening? it seems that a lot of developers are having the same problem without a anwear.. on starckoverflow there are a lot of question about the same issue.

    i think storageItems.getAt(0)  does not return the same object that i get when the target is a StandardDataFormats.bitmap which returns a bitmapStream and createObjectURL works perfectly with that.

    How can i get the URL for an image src from this item extracted from storageItems.getAt(0) ? createObjectURL doesnt work with that

    Saturday, March 1, 2014 8:37 PM
  • A repro would help here. I took the Share source app sample and the Share target app sample as a test. The source app sample can select multiple files in scenario X for this purpose.

    I modified target.html in the Target sample to include this line:

    <div><img id="testImage1" src="#" style="height: 300px; width: 300px" /></div>
    And in target.js, I located the place where it looks for the storage items and added the last two lines:
    if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.storageItems)) {
        shareOperation.data.getStorageItemsAsync().done(function (storageItems) {
            var fileList = "";
            var u = URL.createObjectURL(storageItems.getAt(0), { oneTimeOnly: true });
            document.getElementById("testImage1").src = u;
    
    And the first image shows just fine when I share from the source sample. What are you using as a share source to test your code? It sounds like the StorageFile objects in the data package aren't actually correct.

    Monday, March 3, 2014 11:23 PM