client/js/s3/request-signer.js
function(id, toBeSigned) {
            var params = toBeSigned,
                signatureConstructor = toBeSigned.signatureConstructor,
                signatureEffort = new qq.Promise(),
                queryParams;

            if (options.signatureSpec.version === 4) {
                queryParams = {v4: true};
            }

            if (credentialsProvider.get().secretKey && qq.CryptoJS) {
                if (credentialsProvider.get().expiration.getTime() > Date.now()) {
                    determineSignatureClientSide(id, toBeSigned, signatureEffort);
                }
                // If credentials are expired, ask for new ones before attempting to sign request
                else {
                    credentialsProvider.onExpired().then(function() {
                        determineSignatureClientSide(id, toBeSigned,
                            signatureEffort,
                            credentialsProvider.get().accessKey,
                            credentialsProvider.get().sessionToken);
                    }, function(errorMsg) {
                        options.log("Attempt to update expired credentials apparently failed! Unable to sign request.  ", "error");
                        signatureEffort.failure("Unable to sign request - expired credentials.");
                    });
                }
            }
            else {
                options.log("Submitting S3 signature request for " + id);

                if (signatureConstructor) {
                    signatureConstructor.getToSign(id).then(function(signatureArtifacts) {
                        params = {headers: signatureArtifacts.stringToSignRaw};
                        requester.initTransport(id)
                            .withParams(params)
                            .withQueryParams(queryParams)
                            .send();
                    }, function (err) {
                        options.log("Failed to construct signature. ", "error");
                        signatureEffort.failure("Failed to construct signature.");
                    });
                }
                else {
                    requester.initTransport(id)
                        .withParams(params)
                        .withQueryParams(queryParams)
                        .send();
                }

                pendingSignatures[id] = {
                    promise: signatureEffort,
                    signatureConstructor: signatureConstructor
                };
            }

            return signatureEffort;
        }
function(id, toBeSigned) {
            var params = toBeSigned,
                signatureConstructor = toBeSigned.signatureConstructor,
                signatureEffort = new qq.Promise(),
                queryParams;

            if (options.signatureSpec.version === 4) {
                queryParams = {v4: true};
            }

            if (credentialsProvider.get().secretKey && qq.CryptoJS) {
                if (credentialsProvider.get().expiration.getTime() > Date.now()) {
                    determineSignatureClientSide(id, toBeSigned, signatureEffort);
                }
                // If credentials are expired, ask for new ones before attempting to sign request
                else {
                    credentialsProvider.onExpired().then(function() {
                        determineSignatureClientSide(id, toBeSigned,
                            signatureEffort,
                            credentialsProvider.get().accessKey,
                            credentialsProvider.get().sessionToken);
                    }, function(errorMsg) {
                        options.log("Attempt to update expired credentials apparently failed! Unable to sign request.  ", "error");
                        signatureEffort.failure("Unable to sign request - expired credentials.");
                    });
                }
            }
            else {
                options.log("Submitting S3 signature request for " + id);

                if (signatureConstructor) {
                    signatureConstructor.getToSign(id).then(function(signatureArtifacts) {
                        params = {headers: signatureArtifacts.stringToSignRaw};
                        requester.initTransport(id)
                            .withParams(params)
                            .withQueryParams(queryParams)
                            .send();
                    }, function (err) {
                        options.log("Failed to construct signature. ", "error");
                        signatureEffort.failure("Failed to construct signature.");
                    });
                }
                else {
                    requester.initTransport(id)
                        .withParams(params)
                        .withQueryParams(queryParams)
                        .send();
                }

                pendingSignatures[id] = {
                    promise: signatureEffort,
                    signatureConstructor: signatureConstructor
                };
            }

            return signatureEffort;
        }
function ( id , toBeSigned ) { var params = toBeSigned , signatureConstructor = toBeSigned . signatureConstructor , signatureEffort = new qq . Promise ( ) , queryParams ; if ( options . signatureSpec . version === 4 ) { queryParams = { v4 : true } ; } if ( credentialsProvider . get ( ) . secretKey && qq . CryptoJS ) { if ( credentialsProvider . get ( ) . expiration . getTime ( ) > Date . now ( ) ) { determineSignatureClientSide ( id , toBeSigned , signatureEffort ) ; } // If credentials are expired, ask for new ones before attempting to sign request else { credentialsProvider . onExpired ( ) . then ( function ( ) { determineSignatureClientSide ( id , toBeSigned , signatureEffort , credentialsProvider . get ( ) . accessKey , credentialsProvider . get ( ) . sessionToken ) ; } , function ( errorMsg ) { options . log ( "Attempt to update expired credentials apparently failed! Unable to sign request.  " , "error" ) ; signatureEffort . failure ( "Unable to sign request - expired credentials." ) ; } ) ; } } else { options . log ( "Submitting S3 signature request for " + id ) ; if ( signatureConstructor ) { signatureConstructor . getToSign ( id ) . then ( function ( signatureArtifacts ) { params = { headers : signatureArtifacts . stringToSignRaw } ; requester . initTransport ( id ) . withParams ( params ) . withQueryParams ( queryParams ) . send ( ) ; } , function ( err ) { options . log ( "Failed to construct signature. " , "error" ) ; signatureEffort . failure ( "Failed to construct signature." ) ; } ) ; } else { requester . initTransport ( id ) . withParams ( params ) . withQueryParams ( queryParams ) . send ( ) ; } pendingSignatures [ id ] = { promise : signatureEffort , signatureConstructor : signatureConstructor } ; } return signatureEffort ; }
On success, an object containing the parsed JSON response will be passed into the success handler if the
request succeeds.  Otherwise an error message will be passed into the failure method.

@param id File ID.
@param toBeSigned an Object that holds the item(s) to be signed
@returns {qq.Promise} A promise that is fulfilled when the response has been received.
On success an object containing the parsed JSON response will be passed into the success handler if the request succeeds . Otherwise an error message will be passed into the failure method .