Article View: borland.public.jbuilder.java.language
Article #7733file upload to a webserver
From: Carsten Elshoff
Date: Mon, 21 May 2001 08:10
Date: Mon, 21 May 2001 08:10
31 lines
1998 bytes
1998 bytes
Hi,
I'm facing the problem that I have to upload a file to a webserver using
http (not ftp!). As I've learned from searching through some pieces of
code this is normally done by using the http method "PUT".
Well, so far I've configured my webserver that way it accepts "put"
requests, but my application still does not create any files. The
general idea is this:
// read file into StringBuffer
URL urlUpload = new URL (urlString);
urlUploadConn = (HttpURLConnection)urlUpload.openConnection();
urlUploadConn.setDoInput (true);
urlUploadConn.setUseCaches (false);
urlUploadConn.setRequestMethod("PUT");
// create an outputStream
outputTo = new DataOutputStream (urlWriteThereConn.getOutputStream ());
outputTo.flush();
outputTo.close();
When I try to create the file via DataOutputStream I receive an
java.net.protocol exception saying "cannot write after reading" (this is
not the exact message, hopefully I can provide this later)!
What am I doing wrong? Do I have to set anything else before creating a
file on a server? Any help is greatly appreciated!!
Thanks in advance,
Carsten
Technical Details
Message-ID:
<3B08CD66.32D80AF8@cm-and-ce.de>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!netnews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,6c7a688696aa247d,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-21 01:40:06 PST Message-ID: <3B08CD66.32D80AF8@cm-and-ce.de> Date: Mon, 21 May 2001 10:10:15 +0200 From: Carsten Elshoff <carsten@cm-and-ce.de> X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: file upload to a webserver Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 194.59.247.131 X-Trace: dnews 990432616 194.59.247.131 (21 May 2001 01:10:16 -0700) Lines: 35 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!netnews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews