Re: my PUT's are being scrambled, any suggestions?

There is a similar problem and you could look at the 2 solutions at:-
http://www.hotdispatch.com/view-task-provider?ID=11846974
I wrote the first solution which is actually just diagnosis tips.
The second solution suggest that utf-8 encoding doesn't work.
The real solution probably remains for you to find.
Chris.

Bob Schader wrote:
> 
> 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 20:26:57 UTC