RFC 1867-compatibe File Upload

160 views
Skip to first unread message

CI-CUBE

unread,
Jan 25, 2010, 11:26:05 AM1/25/10
to Google Web Toolkit
Hi @ all,

I'm looking for an RFC 1867-compatible, pure (non-UI) file upload
functionality to be used at [Smart]GWT's client side. It would be
perfect if the code could provide a callback to render a progress bar.

Is there something like that, maybe a JSNI wrapper to a JS library,
available?

Thx in advance,

Ekki

* GWT Rocks! * SmartGWT Rocks Even Harder! * SmartGWT PRO 2.0,
GWT 2.0, Jetty 7.0.0, Eclipse 3.5.1, JRE 1.6.0_16 *
For Evaluation only: MySQL 5.1.41, Connector/J 5.1.10

*** www.EasternGraphics.com/X-4GPL ***

Lothar Kimmeringer

unread,
Jan 25, 2010, 11:43:07 AM1/25/10
to google-we...@googlegroups.com
CI-CUBE schrieb:

> I'm looking for an RFC 1867-compatible, pure (non-UI) file upload
> functionality to be used at [Smart]GWT's client side.

FormPanel.setEncoding(FormPanel.ENCODING_MULTIPART)
should provide that kind of functionality.

> It would be
> perfect if the code could provide a callback to render a progress bar.

I'm not aware of such a thing but defining a function in a
RemoteServiceServlet returning the currently received bytes
of the parallel running upload, shouldn't be that hard to
be implemented by yourself.


Regards, Lothar

Martin Trummer

unread,
Jan 26, 2010, 8:19:52 AM1/26/10
to Google Web Toolkit
I'm not sure, what you mean with non-UI and on the other hand
you want to display a progressbar.
maybe you want a pure-GWT implementation without any 3rd party stuff
like flash or applets?

if so, this may be what you are looking 4:
http://code.google.com/p/gwtupload/

Alex opn

unread,
Dec 4, 2012, 10:46:36 AM12/4/12
to google-we...@googlegroups.com
Looks good! How about making GWT Uploader available via maven? : )

Am Dienstag, 4. Dezember 2012 04:09:34 UTC+1 schrieb Shawn Quinn:
The GWT Uploader project also provides callbacks for file upload progress events, all on the client side:


Thanks,

      -Shawn

Thad

unread,
Dec 5, 2012, 4:19:18 PM12/5/12
to google-we...@googlegroups.com
On Monday, December 3, 2012 10:09:34 PM UTC-5, Shawn Quinn wrote:
The GWT Uploader project also provides callbacks for file upload progress events, all on the client side:


Thanks,

      -Shawn

Shawn,

The demos look very impressive so I thought I'd give it a try. I've several places in my current project where I upload files, but my progress bar solution does not work so well with IE (as in 15%, loooong wait, Done!).

I'm quickly hitting an exception with Uploader. Maybe you have some insight.

I use UiBinder throughout. Since Uploader doesn't have UiBinder tags, I thought I could put in a SimplePanel then assign Uploader to it. In my FooViewImpl.ui.xml I add:

  <g:HTMLPanel'>
      <div>
        <g:Label ui:field='progress'></g:Label>
        <g:SimplePanel ui:field='uploadRaw'></g:SimplePanel>
      </div>
...

In FooViewImpl.java I add

  @UiField
  Label progress;
  @UiField
  SimplePanel uploadRaw;

  public FooViewImpl() {
    initWidget(uiBinder.createAndBindUi(this));

    // uploader
    JSONObject params = new JSONObject();
    params.put("fileType", new JSONString("raw text"));
    Uploader uploader = new Uploader()
      .setUploadURL(GWT.getModuleBaseURL()+"/uploadInput")
      .setButtonText("Upload")
      .setPostParams(params);
    uploader.setUploadProgressHandler(new UploadProgressHandler() {
      @Override
      public boolean onUploadProgress(UploadProgressEvent evt) {
        progress.setText(NumberFormat.getPercentFormat().format(
            evt.getBytesComplete() / evt.getBytesTotal()));
        return true;
      }
    });
    uploadRaw.setWidget(uploader);

This is pretty much the quick start at http://www.moxiegroup.com/moxieapps/gwt-uploader/quickstart.jsp but allowing for UiBinder.

When I click the "Upload" in the UI, I get the error below. I don't see Uploader in the stack trace to I dunno where to start.

Thanks.

Uncaught exception: com.google.gwt.event.shared.UmbrellaException: Exception caught: null
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:662)
Uncaught exception: com.google.gwt.event.shared.UmbrellaException: Exception caught: null
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
    at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
    at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:662)
Reply all
Reply to author
Forward
0 new messages