client/js/s3/multipart.initiate.ajax.requester.js
function handleInitiateRequestComplete(id, xhr, isError) {
        var promise = pendingInitiateRequests[id],
            domParser = new DOMParser(),
            responseDoc = domParser.parseFromString(xhr.responseText, "application/xml"),
            uploadIdElements, messageElements, uploadId, errorMessage, status;

        delete pendingInitiateRequests[id];

        // The base ajax requester may declare the request to be a failure based on status code.
        if (isError) {
            status = xhr.status;

            messageElements = responseDoc.getElementsByTagName("Message");
            if (messageElements.length > 0) {
                errorMessage = messageElements[0].textContent;
            }
        }
        // If the base ajax requester has not declared this a failure, make sure we can retrieve the uploadId from the response.
        else {
            uploadIdElements = responseDoc.getElementsByTagName("UploadId");
            if (uploadIdElements.length > 0) {
                uploadId = uploadIdElements[0].textContent;
            }
            else {
                errorMessage = "Upload ID missing from request";
            }
        }

        // Either fail the promise (passing a descriptive error message) or declare it a success (passing the upload ID)
        if (uploadId === undefined) {
            if (errorMessage) {
                options.log(qq.format("Specific problem detected initiating multipart upload request for {}: '{}'.", id, errorMessage), "error");
            }
            else {
                options.log(qq.format("Unexplained error with initiate multipart upload request for {}.  Status code {}.", id, status), "error");
            }

            promise.failure("Problem initiating upload request.", xhr);
        }
        else {
            options.log(qq.format("Initiate multipart upload request successful for {}.  Upload ID is {}", id, uploadId));
            promise.success(uploadId, xhr);
        }
    }
function handleInitiateRequestComplete(id, xhr, isError) {
        var promise = pendingInitiateRequests[id],
            domParser = new DOMParser(),
            responseDoc = domParser.parseFromString(xhr.responseText, "application/xml"),
            uploadIdElements, messageElements, uploadId, errorMessage, status;

        delete pendingInitiateRequests[id];

        // The base ajax requester may declare the request to be a failure based on status code.
        if (isError) {
            status = xhr.status;

            messageElements = responseDoc.getElementsByTagName("Message");
            if (messageElements.length > 0) {
                errorMessage = messageElements[0].textContent;
            }
        }
        // If the base ajax requester has not declared this a failure, make sure we can retrieve the uploadId from the response.
        else {
            uploadIdElements = responseDoc.getElementsByTagName("UploadId");
            if (uploadIdElements.length > 0) {
                uploadId = uploadIdElements[0].textContent;
            }
            else {
                errorMessage = "Upload ID missing from request";
            }
        }

        // Either fail the promise (passing a descriptive error message) or declare it a success (passing the upload ID)
        if (uploadId === undefined) {
            if (errorMessage) {
                options.log(qq.format("Specific problem detected initiating multipart upload request for {}: '{}'.", id, errorMessage), "error");
            }
            else {
                options.log(qq.format("Unexplained error with initiate multipart upload request for {}.  Status code {}.", id, status), "error");
            }

            promise.failure("Problem initiating upload request.", xhr);
        }
        else {
            options.log(qq.format("Initiate multipart upload request successful for {}.  Upload ID is {}", id, uploadId));
            promise.success(uploadId, xhr);
        }
    }
function handleInitiateRequestComplete ( id , xhr , isError ) { var promise = pendingInitiateRequests [ id ] , domParser = new DOMParser ( ) , responseDoc = domParser . parseFromString ( xhr . responseText , "application/xml" ) , uploadIdElements , messageElements , uploadId , errorMessage , status ; delete pendingInitiateRequests [ id ] ; // The base ajax requester may declare the request to be a failure based on status code. if ( isError ) { status = xhr . status ; messageElements = responseDoc . getElementsByTagName ( "Message" ) ; if ( messageElements . length > 0 ) { errorMessage = messageElements [ 0 ] . textContent ; } } // If the base ajax requester has not declared this a failure, make sure we can retrieve the uploadId from the response. else { uploadIdElements = responseDoc . getElementsByTagName ( "UploadId" ) ; if ( uploadIdElements . length > 0 ) { uploadId = uploadIdElements [ 0 ] . textContent ; } else { errorMessage = "Upload ID missing from request" ; } } // Either fail the promise (passing a descriptive error message) or declare it a success (passing the upload ID) if ( uploadId === undefined ) { if ( errorMessage ) { options . log ( qq . format ( "Specific problem detected initiating multipart upload request for {}: '{}'." , id , errorMessage ) , "error" ) ; } else { options . log ( qq . format ( "Unexplained error with initiate multipart upload request for {}.  Status code {}." , id , status ) , "error" ) ; } promise . failure ( "Problem initiating upload request." , xhr ) ; } else { options . log ( qq . format ( "Initiate multipart upload request successful for {}.  Upload ID is {}" , id , uploadId ) ) ; promise . success ( uploadId , xhr ) ; } }
Called by the base ajax requester when the response has been received.  We definitively determine here if the
"Initiate MPU" request has been a success or not.

@param id ID associated with the file.
@param xhr `XMLHttpRequest` object containing the response, among other things.
@param isError A boolean indicating success or failure according to the base ajax requester (primarily based on status code).
Called by the base ajax requester when the response has been received . We definitively determine here if the Initiate MPU request has been a success or not .