locked
Got WinRTError: The parameter is incorrect by using BackgroundUploader, but i think of the format should be right.

    Question

  • I try to use BackgroundUploader to upload to YouTube as following codes:

    --------------------------------------------------------------
    function scenario2UploadFileToYT(upload_location) {
            try {


                     var uploader = Windows.Networking.BackgroundTransfer.BackgroundUploader();
                     var destinationUri = Windows.Foundation.Uri(upload_location);

                     uploader.setRequestHeader("Content-Type", selectedFile.contentType);
                     uploader.setRequestHeader("Content-Length", selectedFile.size);
                     uploader.setSourceFile(selectedFile);
                    
                     promiseUI = uploader.createUpload(destinationUri);
                     return promiseUI;


            } catch (e) {
                // Exception will be thrown if destinationURI is <Placeholder>
                sdkSample.displayError(e + "Ensure you defined the destination URI of the server to upload to.");
            }
    }
    --------------------------------------------------------------

     

    and this format is according YouTube Developers Guide (http://code.google.com/intl/zh-TW/apis/youtube/2.0/developers_guide_protocol.html#Resumable_uploads):

     

    --------------------------------------------------------------
    PUT <upload_url> HTTP/1.1
    Host: uploads.gdata.youtube.com
    Content-Type: <video_content_type>
    Content-Length: <content_type>

    <Binary_file_data>
    --------------------------------------------------------------


    finally, i got "WinRTError: The parameter is incorrect." message,
    and i cannot upload video, I don't know why, Please help for this. Thanks for any advice.


    • Edited by H_Y_J Thursday, February 2, 2012 12:19 PM
    Thursday, February 2, 2012 12:18 PM

Answers