nsCOMPtr<nsIFTPChannel> ftpChannel(do_QueryInterface(channel)); ftpChannel->SetUploadStream(uploadStream);
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(channel)); uploadChannel->SetUploadStream(uploadStream, nsnull);
main(int argc, char* argv[]){    nsresult rv;    if (argc < 2) {        printf("usage: %s <url> <file-to-upload>\n", argv[0]);        return -1;    }    char* uriSpec  = argv[1];    char* fileName = argv[2];        rv = NS_AutoregisterComponents();    if (NS_FAILED(rv)) return rv;    // Create the Event Queue for this thread...    nsCOMPtr<nsIEventQueueService> eventQService =              do_GetService(kEventQueueServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    rv = eventQService->CreateThreadEventQueue();    if (NS_FAILED(rv)) return rv;    eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);    nsCOMPtr<nsIIOService> ioService(do_GetService(kIOServiceCID, &rv));    // first thing to do is create ourselves a stream that    // is to be uploaded.    nsCOMPtr<nsIInputStream> uploadStream;    rv = NS_NewPostDataStream(getter_AddRefs(uploadStream),                              PR_TRUE,                              fileName,                              0, ioService);    if (NS_FAILED(rv)) return rv;    // create our url.    nsCOMPtr<nsIURI> uri;    rv = NS_NewURI(getter_AddRefs(uri), uriSpec);    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIChannel> channel;    rv = ioService->NewChannelFromURI(uri, getter_AddRefs(channel));    if (NS_FAILED(rv)) return rv;	    // since we are testing now, we know it is a ftp url.      // QI and set the upload stream    nsCOMPtr<nsIFTPChannel> ftpChannel(do_QueryInterface(channel));    ftpChannel->SetUploadStream(uploadStream);    // create a dummy listener    InputTestConsumer* listener;        listener = new InputTestConsumer;    NS_IF_ADDREF(listener);    if (!listener) {        NS_ERROR("Failed to create a new stream listener!");        return -1;;    }    channel->AsyncOpen(listener, nsnull);    while ( 1 ) {#ifdef WIN32        MSG msg;                if (GetMessage(&msg, NULL, 0, 0)) {            TranslateMessage(&msg);            DispatchMessage(&msg);        } else {            gKeepRunning = 0;    }#else#ifdef XP_MAC    /* Mac stuff is missing here! */#else    PLEvent *gEvent;    rv = gEventQ->WaitForEvent(&gEvent);    rv = gEventQ->HandleEvent(gEvent);#endif /* XP_UNIX */#endif /* !WIN32 */    }    NS_ShutdownXPCOM(nsnull);    return 0;}