Hi Everyone,
now I'm using HttpClient to upload file, but still unsuccessful! The error
code is 415, unsupported media, but the file I want to update is just a JPG!
Before that, I can use
http://admin:[email protected]:8080/content/nemoclient?sling:authRequestLogin=1
to upload files!
So can someone help me to fix this error? Thanks very much!
HttpClient httpClient=new HttpClient();
httpClient.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("admin",
"admin");
httpClient.getState().setCredentials(new AuthScope("141.83.80.149", 8080,
AuthScope.ANY_REALM), defaultcreds);
PutMethod put = new PutMethod(transferURL);
InputStream stream;
stream = new FileInputStream(localFile);
RequestEntity entity = new InputStreamRequestEntity(stream);
put.setRequestEntity(entity);
put.setDoAuthentication(true);
HttpClientParams params=new HttpClientParams();
params.setIntParameter("sling:authRequestLogin", 1);
httpClient.setParams(params);
httpClient.executeMethod(put);
On Fri, Nov 19, 2010 at 8:39 AM, Justin Edelson <[email protected]>wrote:
> On 11/19/10 10:21 AM, Vicary Archangel wrote:
> > Hi Bertrand,
> >
> > The output of AMF requests is actually bitwise formatted variables, seems
> > somewhat like a pattern of data type, some delimiters and the variable
> > contents.
> >
> > Basically AMF RPCs does not require channels other than HTTP, even with
> data
> > returns after a function call. Tho whole serialization/deserialization
> > process only touches raw POST data and the http output stream, in byte
> > level. I believe if PHP can handle this, Sling should be able to do it
> even
> > better as long as it is based on Java.
> >
> > What I seek more than AMFPHP is RTMP streams, which allows the client to
> do
> > true video streaming, in contrast to the PHP's pseudo streaming.
> >
> > RTMP streams, which must then implemented with TCP connections, also
> enables
> > some Flash things called Remote Shared Object, this involved in
> > communication between http request threads with some sort of synchronized
> > data (either in memory or file system).
> >
> > There is two major open source AMF server that already implemented RTMP
> > streaming, written in Java.
> > Red5 Server: http://osflash.org/red5
> > BlazeDS: http://opensource.adobe.com/wiki/display/blazeds/BlazeDS
>
> Have you looked at just running BlazeDS or LCDS inside Felix/Sling? That
> seems much simpler than writing your own RTMP server.
>
> Justin
>
>
> >
> > You can read the spec of RTMP alone here at
> > http://www.adobe.com/devnet/rtmp.html.
> >
> > Hope I make it clear enough. =]
> >
> > Vic
> >
> > On Fri, Nov 19, 2010 at 5:29 PM, Bertrand Delacretaz <
> [email protected]
> >> wrote:
> >
> >> Hi Vic,
> >>
> >> On Fri, Nov 19, 2010 at 3:43 AM, Vicary Archangel <[email protected]>
> >> wrote:
> >>> ...The question is how does Sling handle streaming? And can it send
> >> binary data
> >>> directly with pure JavaScript but not template things?...
> >>
> >> As Felix said, yes, using the HTTP request/response model.
> >>
> >>> In fact I'm seeking the possibility to implement an AMF-HTTP channel in
> >> the
> >>> future.
> >>
> >> Where can we find a quick description of AMF-HTTP?
> >>
> >> I looked at http://en.wikipedia.org/wiki/Action_Message_Format and
> >> that seems to imply that the client switches to something else than
> >> HTTP after the initial request to the gateway URL. That would be
> >> possible with Sling, but not out of the box.
> >>
> >> -Bertrand
> >>
> >
>
>
--
Best regards
Li Zhongmiao
Digital Media, College of Computer Science, Zhejiang University