- From: Bob Schader <rschader@product-des.com>
- Date: Sun, 25 Feb 2001 15:31:32 -0500
- To: Jigsaw List <www-jigsaw@w3.org>
Further notes:
I have found example code in an old 1996 message, which I
have now changed mine to match in the following regards:
Changed
InputStream in = new FileInputStream(localFile)
to
InputStream in = new BufferedInputStream(new FileInputStream(
localFile));
and changed the request.setValue calls for ContentLength and
ContentType to request.setContentLength() and
request.setContentType() calls.
I have added a in.close() call when done and also added
debug calls to request.dump() and reply.dump(), all of which
seems to output valid headers and replies, but:
I am still getting file corruption on the uploaded file!
Getting Desparate,
Bob Schader
Bob Schader wrote:
>
> Intro to my problem:
> I finally thought I found a way to monitor HTTP PUT uploads
> by using the w3c client java library included with Winie and
> also part of Jigsaw, so I could implement a pure java
> upload app, as opposed to my current method of incorporating
> libcurl and using native calls. I previously found the
> standard HttpURLConnection classes in java inadaquate for this
> purpose and had other problems trying to use the HttpClient
> library from www.innovations.ch
>
> After studying the source code to Winie's JW and JWPut classes,
> and reading the Javadocs for the Jigsaw client library, I tried
> to implement it, and thought I was doing pretty good at it,
> until I decided to verify that my uploaded files were OK, which
> I discovered they weren't. So, I tried backing up, removing
> StreamMonitors, ByteCountInputStreams, etc, to see if those
> items were causing the problems, which they weren't. I now have
> the following compacted code, that seems to be uploading files
> with no errors, but the zip files I am uploading are being
> corrupted. I am 99% certain it is not on the server side, as
> I have never had any other problems uploading files using PUT.
>
> Hopefully someone more versed in the client library code could
> point out something I may have missed here:
>
> try
> {
> HttpCredential credential = null;
> HttpManager manager = HttpManager.getManager() ;
> org.w3c.www.protocol.http.Request request = manager.createRequest();
> request.setObserver(this);
> request.setMethod("PUT");
> request.setURL(new URL(CompleteURL));
> request.setValue("Content-Type", "application/octet-stream");
> request.setValue("Content-Length", String.valueOf(localFlen));
> Base64Encoder encoder = new Base64Encoder(AuthUser + ":"
> + AuthPasswd);
> credential = HttpFactory.makeCredential("Basic");
> credential.setAuthParameter("cookie", encoder.processString());
> request.setAuthorization(credential);
> request.setExpect("100-continue");
>
> InputStream in = new FileInputStream(localFile);
>
> if(in != null)
> {
> request.setOutputStream(in);
> }
> if (request != null) {
> org.w3c.www.protocol.http.Reply reply =
> manager.runRequest(request);
> } else {
> System.out.println("request object is null!");
> }
> } catch (HttpException ex) {
> System.out.println(ex.getMessage());
> } catch(FileNotFoundException fnfex) {
> System.out.println(fnfex.getMessage());
> } catch (MalformedURLException mfuex) {
> System.out.println(mfuex.getMessage());
> } catch (IOException ioex) {
> System.out.println(ioex.getMessage());
> }
>
> Thanks in advance,
> Bob Schader
Received on Sunday, 25 February 2001 15:32:24 UTC