Help with HttpClient for file download

I am writing a class to download files from a website.
The site gave me a user name and password for login
I need to write codes to login automatically using the userName and password the site gave me.
Please I need some help on how to do this.
Thanks
Cypray

The following in google returns a number of links that look like it discusses this. I know as well that the user/pwd issue has been discussed on this site before.
java http "file download"

Similar Messages

  • Peformance Turning for File Download / Upload with Enabled SharePoint Audit

    Greetings all, may I ask your help for Peformance Issues?
    Background:
    I tried to create a ASP.NET Web Page to download/upload/list SharePoint file and deployed to IIS website in same application server (will NOT use web part as some users are NOT allowed to direct access confidential workspace)
    Besides, for Audit Log record purpose, the page will impersonate (without password) the logged in user:
    SPUserToken userToken = web.AllUsers[user].UserToken;
    SPSite s = new SPSite(siteStr, userToken);
    For File Listing, the web service can provide fast response, and we are using service A/C for connection (as no auting for listing, but require audit for file download upload)
    Several implemeation options tested for File Downloiad / Upload, but issues occured and finding listed below:
    Issues
    1) SharePoint Object Model
    When I open Site (using new SPSite), it's too slow to respond. (under 1s for all operations, but require 10~50s for open SPSIte. e.g.
    using(SPSite s = new SPSite(siteStr) //50s
    How can I download/upload file without open SPSite object (using SharePoint object model, but user token should be kept to allow SHarePoint identifiy user actions. e.g. Updated by Tom, NOT system administrator)?
    2) SharePoint default web service
    For file download, I tried to use SharePoint Web Service for download file, it's quick but how can SharePoint record the audit log to downloaded user, and not service A/C? ( e.g. View by Tom, NOT system administrator)
    With Windows SSO solution, please note system should NOT prompt to ask user password for use impersonation
    3) HTTP Request API (for file download)
    As mentioned in point 2, if the system cannot get password from user, SharePoint also recorded service A/C in audit log... ><
    Thank you for your kine attention.
    .NET Beginner 3.5

    Thank you for prompt response, please find my reply with Underline:
    Hi,
    Maybe I'm not quite clear about the architecture you have now.
    Is your asp.net application deployed in separate IIS site but in the same physical server as SharePoint?
    Yes
    "we are using service A/C for connection", can you please explain the 'A/C'?
    Domain User, Local Admin and also SharePoint Service Admin A/C
    Opening SPSite is relatively slower but shouldn't take 50 sec. However it depends on your server hardware configuration. You should meet the minimum hardware requirements for SharePoint.
    Assigned double resources based on minimum hardware requirements.
    For details, 50s is the load test result. But for other SharePoint operation, it takes around/under 3s reponse time.
    Are you using SharePoint Audit log? Exactly If so then why don't you just put the hyperlink to the documents in your asp.net page. User maybe have to login once in SharePoint site but
    it depends on your security architecture. For example if both of your sites in local intranet and you are using windows integrated authentication, SSO will work automatically  User is NOT allowed
    to access SharePoint site/server (not implemented for sepreate server yet, as performance issues occured for
    separate site in same server)  directly from Internet, the
    middle server with web interface created for user request.
    Whatever I understands gives me the feeling that you download the file using HTTPWebRequest C# class. However regarding security it depends on how authentication is setup in asp.net web site and in sharepoint. If both site uses windows integrated security
    and they are in the same server, you can use the following code snippet:
    using (WebClient webClient = new WebClient())
    webClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
    webClient.DownloadFile("file ur in sharepoint", "download directory");
    Thanks, will try and reply later
    But still, as I've mentioned, not quite clear about the whole architecture.
    A) Request Handling
    1) User use browser to request file listing and/or download file (hereafter called: File Download Request) from custom ASP.NET page (Let's say In Server 1, IIS 1)
    2) ASP.NET page  or File Handler ashx (Server 1, IIS 1) call custom web service, SharePoint deault/OOTB web service or using SharePoint Object Model to access SharePoint Document Library (in Server 1,
    IIS 2)
    3) Both SharePoint and IIS Web Site
    (Server 1, IIS 1 & IIS2) using the same service A/C
    4) The web service , File Handler return file obeject to IIS1
    5) IIS 1 reply File Download Request to user
    B) Application Architecture (In testing environment)
    1) no load balancing
    2) 1 DB server (Server 2)
    3) 1 Application Server (with IIS 1 - ASP.NET, IIS 2, SharePoint Web Site with default SharePoint Web Service, IIS 3 SharePoint Admin Site & IIS 4 Custom SharePoint Web Service)
    4) Sepreate AD Server (Server 3)
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com
    .NET Beginner 3.5

  • Problems with signed Applet for File Download under JRE 1.4 (works with 1.3

    Dear all,
    i encountered a very strange behaviour with JRE 1.4x. A signed applet used for file download worked on all platforms (Windows NT, 2000 and XP wth/wthout SP...) until I installed JRE 1.4.x (1.4.1 or 1.4.2)
    I get an EOFException when downloading binary files (for ASCII it works fine) when trying to readByte() from a DataInputStream. But not immideately, but after x bytes in the while-loop. Security is fine (I know there have been changes to that in jre 1.4, the applet itself can be started an runs with ASCII files for transfer)
    Does anyone know, what has changed in jre1.4.
    As I said, it works fine under jre 1.3.x
    The relevant code is below: byte bt = dis.readByte(); causes the error
    try{
    // Get URL from Server
    URL uFile = new URL(sFilename);
    sThisURLFile = uFile.getFile();
    Integer inte = new Integer(i);
    //open input stream for the file on server
    DataInputStream dis = new DataInputStream(new BufferedInputStream
    (uFile.openConnection().getInputStream()));
    //open output stream for the file on local drive
    String sFilenameOnly = sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1);
    int iDotPos = sFilenameOnly.lastIndexOf(".");
    String sExt;
    if (iDotPos > 0) {
    sExt= sFilenameOnly.substring(iDotPos);
    } else {
    sExt = "";
    File fileOut = new File(sDownloadDir + sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1) );
    DataOutputStream dos = new DataOutputStream(new
    BufferedOutputStream(new FileOutputStream(fileOut)));
    //read one byte from input stream, and write that byte to output stream
    long nByte = 0;
    int iCnt = 0;
    iFilesizeDone ++;
    while (nByte < iFilesize){
    String sErrPs = new String();
    try{
    sErrPs = "00";
    byte bt = dis.readByte();
    sErrPs = "01";
    dos.writeByte(bt);
    } catch (EOFException ee)
    System.err.println("internal EOFException: " + ee.getMessage());
    System.out.println("Error Filesize is " nByte " of " iFilesize "---" + sErrPs);
    break;
    nByte++;
    iFilesizeDone ++;
    iCnt ++;
    if(iCnt >= 10240) {
    ShowProgress(nByte, iFilesize, iFilesizeDone, iFilesizeTotal); // repaint does not work during init-procedure
    iCnt = 0;
    line = "Progress: Total: " + ((iFilesizeDone*100)/iFilesizeTotal) + " perc, " + iFilesizeTotal/1024 +" kbytes" ;
    labLine.setText(line);
    //dos.flush(); // improves Client performance (Agent-Call!)
    dis.close();
    dos.close();
    }// End try
    catch (EOFException ee)
    System.err.println("EOFException: " + ee.getMessage()e);
    catch (SecurityException se)
    System.err.println("SecurityException: " + se.getMessage());
    catch (IOException ioe)
    System.err.println("IOException: " + ioe.getMessage());

    perhaps they've changed something with the file blocking.
    btw, you should try to use something like this
    DataInputStream dis = new DataInputStream(is);
    byte[] buffer=new byte[8192];
    int numBytesRead;
    while ( dis.available()>0 ) {
         numBytesRead = dis.read(buffer);
    }               

  • JSF error message: Automatic prompting for file download

    This is a weird problem. I have a JSF application wherin I popup a new window on a submit button.
    The window opens a test.jsf page that redirects the output to a servlet1.
    Servlet then based on some parameters does a sendRedirectI() to different servlets out of context.
    Now the issue is that when the output is redirected to out of context servlet, that returns a file download.
    If in IE browser, if one does not do a setting of "Automatic prompting for file download", this window that I had opened on submit buttton vanishes in a jiffy. If the IE setting is done, it shows the file download correctly.
    I would want to show the user some kind of message by which he/she understands that this IE setting has to be done.
    I have tried several ways:
    1. Javascript: window.onbeforeunload on the test.jsf so that when the window unloads i can show some message. But since test.jsf forwards to servlet1, the html page generated does not show my script.
    2. I also tried checking if some windows registry can help me understand the setting.
    3. I tried writing in response object the javascript and then redirecting it to servlet out of context. But I guess sendRedirect() does a new request, so this did not help.
    Can anyone help? I am not sure if I am able to explain my problem correctly.
    Yani

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • Java WebDynpro's and IE security settings for file download

    We have a EP 7.0 SP13 environment on which we have deployed a number of own developed java webdynpro's. In some of these webdynpro's we provide the file download functionality. The portal and webdynpro's are used by both internal personnel and external customers.
    On the other hand the default Internet security settings for Internet Explorer, disable "Automatic prompting for file downloads".
    When a user, with these default security settings active, tries to use our webdynpro's file download functionality, the screen seems to refreshes but no file download starts. When (s)he retries, the session runs for some minutes and gives following error message:
    "com.sap.tc.webdynpro.services.session.LockException: Thread SAPEngine_Application_Thread[impl:3]_20 failed to acquire exclusive lock on client session ClientSession".
    This behavior is explained in SAPNote 1234847. Webdynpro provides a single-thread module, meaning a user session is blocked for the during of the request. And because the previous file download isn't yet completed the new try can't start.
    Issue now, although the users IE settings allow file downloads and don't block pop up's, he can't download the file and even isn't made aware of the cause of the failure.
    How can we avoid this issue, without having to communicate the
    application requires specific browser settings?

    Welcome to the Apple Support Communities
    See > http://support.apple.com/kb/HT5290
    You can install the program using different ways:
    1. Right-click the application installer and choose Open.
    2. Go to System Preferences > Security and Privacy and select Anywhere in Allow applications downloaded from

  • Drop-down Menu to Open URL for File Download

    I am using Adobe Captivate 5.5 and was wondering if it is possible to create a drop-down menu that can be used to open different URLs for file downloads, kind of like the Attachments button Presenter has. Captivate seems to have a dropdown widget available but I can't tell if this would work for this purpose.

    Hi Theo
    You can use any composition to create a menu with setting for show target on rollover and then link targets to specific pages.
    Adobe Muse CC 7.0 Tutorial | Beautiful Graphic Navigation - YouTube
    Thanks,
    Sanjit

  • Any way to set up iWeb pages for file download / sharing?

    I have been using .Mac Homepage to set up several web pages to share audio files with my clients. I have been able to set up a different web page for each client, each with their own password, with files there for them to download.
    Is there a way to duplicate this using iWeb now that .mac homepage sites are going away? I don't want the audio to stream, I just want to make the files available for downloading, and don't see any page templates in iWeb '08 for file downloading.
    I know that I can use mobileme's new file sharing feature to email links to individual files, but this doesn't work as well as having all the files downloadable on one or more web pages.

    If you have all of the sites in one domain file you should be able to upload only the changed pages but it's been a while since I used 08 so don't remember. You can move each site into its own domain file so that only that site is edited and published. And if you're publishing directly to mobile me only the edited files should be uploaded.
    I use iWebSites to manage over 75 individual sites.. It lets me create multiple sites and multiple domain files.
    If you have multiple sites in one domain file here's the workflow I used to split them into individual site files with iWebSites. Be sure to make a backup copy of your original Domain.sites files before starting the splitting process and move it to another location on your HD until you're satisfied the separation process is completed and what you want.
    This lets me edit several sites and only republish the one I want. Make sure you're running the lastest version of iWeb, 2.0.4 I believe.
    An example of files set up for immediate download is Toad's Cellar. Each linked is linked to a zipped file which downloads when clicked on. The site could be password protected if so desired.
    OT

  • Automatic prompting for file download

    I am using a File Download Servlet. Theres a setting in IE under Securiy Settings --> Downloads--->Automatic Prompting for File Downloads.If I have this disabled, I am able to download the file.If its enabled, I am unable to download the file successfully. Anyone have faced this problem before?

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    I need help with a PDF file that is an image, the "Read Out Loud' option does not work, please help!

    You mean an image such as a scanned document?
    If that is the case, the file doesn't contain any text for Reader Out Loud to read. In order to fix that, you would need an application such as Adobe Acrobat that does Optical Character Recognition to convert the images to actual text.
    You can also try to export the file as a Word document or something else using ExportPDF which I believe offers OCR and is cheaper than Acrobat.

  • Help with updates for CS6

    I need help installing latest updates for CS6.  I have Win 7 and have tried updating from the Help - Updates menu.  The error is:  U43M1D207.

    Thanks for your response.  I am in the United States in So. Arizona.
    Date: Fri, 5 Oct 2012 12:21:45 -0600
    From: [email protected]
    To: [email protected]
    Subject: Help with updates for CS6
    Re: Help with updates for CS6 created by Jeff A Wright in Downloading, Installing, Setting Up - View the full discussion
    Crunkle1 you are welcome to work directly with our support team for guided assistance.  If you go to http://www.adobe.com/ and select Help and Contact Us you should be given the option to contact our support team via telephone.  Which country/region are you in?
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4752605#4752605
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4752605#4752605
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4752605#4752605. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Downloading, Installing, Setting Up by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Adding a new layout for DME for file download

    Hi All,
    How do i add a new layout for file download in DME?
    Thanks
    William Wilstroth

    This problem is solved.
    Need to enhanced the T042O table.

  • Help with building flash files for streaming

    I filmed a product demonstration for a client who wanted to put it on his website.  I edited the footage in PremPro CS4 and exported to Media Encoder as F4V file format.  After encoding imported footage into CS4 Encore, created timeline, chose, Flash from Format and swf for output.  Progressive Download which allows video to begin playing as it is downloaded (I believe), chose destinations and settings.  After transcoding I had 1 file folder, Sources that contained the following files _PGC_Bpge_entryPoint_Bbp_1.f4v, and then 3 separate files, *not* in the file folder called Sources.  They are
    AuthoredContent.xml, FlashDVD.swf, and Index.html.
    I submitted all files to client who gave them to web designer.  Designer said these were the wrong files and he could not use them. I called designer and basically he said I didn't know what I was doing.  I told him he needed all files to put up the flash video.  Anyway, am I missing something, doing something wrong?  Are there other files he needs?  He said he only needed 1 file.  Or is it the designer?  I'm not thin skinned so if it's me please tell me so, so I don't make the same errors.  Thanks.  All suggestions/comments are appreciated!

    <The client wants a control player, i.e. play, stop, pause, etc., that's it, so the viewer can simply provide the function themselves.  This is similar to youtube, blogger, etc.
    The web designer can use what you provided, which does what you describe the client wanting.  But the web designer may need to integrate what Encore provided onto a web page, and the client may not have made the expectations clear and may not know what is needed.  As I said, the Encore to flash player gives almost no options for the player controls and colors etc may be problems.
    <Encore did encode the f4v file.  When I exported from PremPro what preset should I hve chosen -- mpeg2 DVD, flv/f4v.  So the only file he needs in addition to what I gave him is the original f4v file?
    I don't know whether the f4v you exported from Premiere was progressive.  The f4v from Encore might be fine, or you might need to export from Premiere again.
    The other issue is that some "player" with controls needs to be provided by you or the web designer (who may have an issue with the client not getting the designer to lay all this out to begin with).  There are several threads about "flv players" you might check out.  Does the client have video on his site already?  If so, you can figure out what they are using, and it will help with your process.
    should I have chosen "flash server" instead of "progressive".  i must admit i never did this before.  other clients just have me post it to youtube and provide them with embed code.
    It depends on what they want.

  • Begging for help with podcast xml file

    Hey All,
    I have a podcast on iTunes.  I am hosting the xml file and podcast mp3s on a friends server so Im not using any service.  Everything is working and Ive sucessfully added 4 podcasts so far, and it shows up correctly in iTunes on my PC.
    However my podcasts do not showup correct in the iTunes store website, or on idevices.  Meaning, I number my shows 001_"NAME" 002_"NAME" etc.  Yet in the iTunes store they show up out of order.  So my last show is not at the top its at the bottom, and they are all mixed up (like 002, 001, 004, 003 instead of  4,3,2,1)  Also the publish date is the same on two of them (and not what i have in the xml file) and doesnt show up at all on the other two.  I assume this is a problem with the xml file, yet I dont see any problems with it.  But it seems odd that it all works correctly in the actual iTunes program.  Ive tried different code, but im very much a noob at it, and everything i find online is from 5 - 10 years ago or wants you to host your podcasts with their site and I dont need that. 
    Here is the link to the show on the iTunes website so you can see what i mean:  http://itunes.apple.com/us/podcast/your-reality-recap/id501295325
    If anybody can, would you mind checking out the code in my xml file and letting me know if you see anything thats causing this issue?
    I zipped the xml file and put it here:  http://www.ericcurto.com/podcast/YRR.zip
    I would be truly greatfuly for any help with this.  Ive been trying to fix this for days and dont know what else to do. 
    Thanks!
    Eric

    Your feed is at http://www.ericcurto.com/podcast/YourRealityRecap.xml (please always post the feed URL, not its contents or a copy).
    I don't see the issues you mention. The order in the Store and when subscribing is what I would expect:
    The order in the Store depends on clicking the header to the column: the default is the first one. Some of the dates are a day out - this is quite commmon and is probably a time zone issue (it may be different where you are - I'm in the UK). I don't know why you are seeing a garbled order unless you've clicked on one of the other columns in the Store.

  • Set filename for file download

    Hi
    i have a servlet that sends a file to the client to be downloaded. When the client requests the file the dowload dialogue pops asking if the user wants to download/open but the name of the file is always the servlet name were it originates. Is there any way to set the filename and extension in the servlet e.g ExampleResult1234.csv and send this to the client so that when the dialogue pops up it is set?
    Current Servlet Code:
    String output = "some data from database in csv format";
            response.setContentType("application/binary");
         response.getWriter().write(output);Thanks
    David

    It would be nice for the next person who needs help with this if you posted your solutions. :)

  • Implementing file "Save as" functionality for file download api

    Hi,
    I want to implement File Download (Open/Save as/Cancel dialogue box) programmatically.
    I am displaying list of links to document in a web dynpro table and I dont want to set IWDResource data for all entries in table.
    And on Click of a button/link to action, I want to open up a File download box.
    I have URL to the file with me and I'm able to convert it to IWDResource.
    Following are the things available with me for a selected file:-
    -- Complete name of file along with extension
    -- byte[] of file.
    Please help.
    Thanks and regards,
    Amey Mogare

    I could achieve it with following code:-
         String l_str_LinkValue = null;
         String l_str_LinkName = null;
         URL l_url = null;
         InputStream  l_is_inputS = null;
         try {
              l_str_LinkValue = wdContext.currentCtx_vn_KmFolderDataElement().getLinkValue();
              l_str_LinkName = wdContext.currentCtx_vn_KmFolderDataElement().getLinkName();
              l_url = new URL(l_str_LinkValue);
              l_is_inputS = l_url.openStream(); 
              IWDResource res = WDResourceFactory.createResource(l_is_inputS, l_str_LinkName, WDWebResourceType.UNKNOWN, true);
              if(res != null){
                   wdContext.currentContextElement().setFileRes(res);
              }else{
                   myMessage.reportException("Unable to create file", true);
         catch (MalformedURLException mfurle) {
              myMessage.reportException("MalformedURLException : "+mfurle.toString(), true);
              wdContext.currentContextElement().setFileRes(null);
         catch (IOException ioe) {
              myMessage.reportException("IOException : "+ioe.toString(), true);
              wdContext.currentContextElement().setFileRes(null);
         catch (Exception e) {
              myMessage.reportException("Exception : "+e.toString(), true);
              wdContext.currentContextElement().setFileRes(null);

Maybe you are looking for

  • My emails won't display on right hand side of iPad sceen

    Emails won't display their content on the right had side of screen on my iPad , gmail

  • Outbound Proxy - Message Recorded(Commit Missing)

    Dear All, The proxy's are configured correctly, and when tested the message getting created with status as Message Recorded(Commit Missing). SLDCHECK transcation is also sucessfull! No application Log exist at transaction SLG1! What could be the reas

  • ODi Generates random name at HFM load log.

    Hi Gurus, I am using ODI 11.1.1.3 to load data into HFM. I Want the data load log to be attached in an email. The problem is that a random log name is generated. I've opened the IKM and a function generates the random log name (<?=java.lang.System.ge

  • Swf issues in PowerPoint

    I am working with a Captivate 2 file that I updated. Now when I embed it into PowerPoint 2003, it does not work. (It did on the previous presentation before this update) I deleted the old slide, inserted a new slide, used the More Controls > Shockwav

  • Why is Firefox slow after latest update?

    I just updated to v24 and it is really lagging a lot. I've tried resetting, disabling add ons, updating add ons, restarting in safe mode... the whole nine yards. I've done every troubleshooting I can think of and it is still really laggy and slow. I