httpChannel->SetUploadStream( postData );
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel)); NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");  uploadChannel->SetUploadStream( postData, nsnull, -1);
nsStreamTransfer::SelectFileAndTransferLocationSpec( char const *aURL,                                                     nsIDOMWindowInternal *parent,                                                     char const *contentType,                                                     char const *suggestedName,                                                     PRBool      doNotValidate,                                                     nsIInputStream *postData,                                                     nsISupports *cacheKey ) {    nsresult rv = NS_OK;    // Construct URI from spec.    nsCOMPtr<nsIURI> uri;    rv = NS_NewURI( getter_AddRefs( uri ), aURL );    if ( NS_SUCCEEDED( rv ) && uri ) {        // Construct channel from URI.        nsCOMPtr<nsIChannel> channel;        rv = NS_OpenURI( getter_AddRefs( channel ), uri, nsnull );        if ( NS_SUCCEEDED( rv ) && channel ) {            // See if LOAD_FROM_CACHE is called for.            if ( doNotValidate ) {                channel->SetLoadFlags( nsIRequest::LOAD_FROM_CACHE );                if ( cacheKey ) {                  nsCOMPtr<nsICachingChannel> cachingChannel(do_QueryInterface(channel));                  if (cachingChannel) {                    // Say we want it out of the cache only if we have                    // post data. If the stream has already been evicted,                    // we'll put up a dialog before reposting.                    cachingChannel->SetCacheKey(cacheKey,                                                 (postData != nsnull));                  }                }            }            // Post data provided?            if ( postData ) {                // See if it's an http channel.                nsCOMPtr<nsIHttpChannel> httpChannel( do_QueryInterface( channel ) );                if ( httpChannel ) {                    // Rewind stream and attach to channel.                    nsCOMPtr<nsIRandomAccessStore> stream( do_QueryInterface( postData ) );                    if ( stream ) {                        stream->Seek( PR_SEEK_SET, 0 );                        httpChannel->SetUploadStream( postData );                        httpChannel->SetRequestMethod("POST");                    }                }            }            // Transfer channel to output file chosen by user.            rv = this->SelectFileAndTransferLocation( channel, parent, contentType, suggestedName );        } else {          NS_ASSERTION(0,"Failed to open URI");        }    } else {      NS_WARNING("Failed to create URI");    }    return rv;}