`
snoopy7713
  • 浏览: 1148885 次
  • 性别: Icon_minigender_2
  • 来自: 火星郊区
博客专栏
Group-logo
OSGi
浏览量:0
社区版块
存档分类
最新评论

Uploading files with RAP 1.4

    博客分类:
  • RAP
阅读更多

One of the new things in RAP 1.4 is the FileUpload widget in RWT, that replaces the old Upload widget from the sandbox. And there’s some more new upload stuff in the RAP Incubator. Here’s how to use the new features to upload files with RAP 1.4.

The FileUpload is a new widget that wraps the HTML file selection <input> tag. It looks like a button, and when it’s pressed, a native file dialog opens up that lets users select a file from their local file system. On file selection, a SelectionEvent will be fired. You can then programmatically upload the selected file to an http server using FileUpload.submit( URL ).

FileUpload Uploading files with RAP 1.4

In order to receive and store the uploaded files on the server, you also need a server-side component. We created such an upload server component in the RAP Incubator. It’s called FileUploadHandler and it uses the Apache fileupload component internally. It’s included in the bundle org.eclipse.rap.rwt.supplemental.fileupload. This handler accepts file uploads to a certain URL (FileUploadHandler.getUploadUrl()) and delegates the data to a FileUploadReceiver. You can either use the provided DiskFileUploadReceiver or create your own receiver to do whatever you like with the uploaded data: put it into a database, or simple analyze the data and discard it.

Sounds complicated? Well, there’s a much easier way to upload files with RAP 1.4! We’ve encapsulated the entire upload process in an implementation of the SWT FileDialog, which is also available in the incubator.

FileDialog1 Uploading files with RAP 1.4

To make it easy to use, we now provide an update site for the Incubator. To use the FileDialog in your application, all you have to do is to:

  1. include the bundles from the RAP Incubator repository http://download.eclipse.org/rt/rap/1.4/incubator/ in your RAP 1.4 target platform, and
  2. add a bundle dependency to org.eclipse.rap.rwt.supplemental.filedialog to your project (yes, you have to use Require-Bundle here because this bundle contributes a class to the org.eclipse.swt.widgets package, effectively creating a split-package ).

That’s all. Now you can use the FileDialog just like in SWT:

 

  FileDialog fileDialog = new FileDialog( shell, SWT.TITLE | SWT.MULTI );
  fileDialog.setText( "Upload Files" );?
  fileDialog.setAutoUpload( true ); // This API will change, see below!
  fileDialog.open();
  String[] fileNames = fileDialog.getFileNames();

 

After uploading, the dialog closes and the variable fileNames contains the absolute file names of the uploaded files on the server’s file system. There’s an auto-upload feature that is really nice (I think it should be the default) – with autoUpload on, the upload starts immediately after file selection. A user can still press Cancel to prevent the application from using the uploaded files.

Note: Please note that this stuff is in the incubator and not part of the 1.4 release. The API and implementation may (and will) have to change and mature over time. However, if you use the latest version from 1.4/incubator site, you’ll always get a file dialog that will work with RAP 1.4. The server-side upload receiver and the required Apache bundles are also included.

We hope you enjoy these new features. Please try them out, tell us what you think, open bugs for the new stuff, and help us improving them.

Kudos to our new RAP committers Austin Riddle and Cole Markham who created this great new feature!

Update: I mistakenly left out the “.rwt.” from the bundle namespace in the original post, the bundle names are fixed now in the text.

Update: The 1.4 incubator repository has been updated with a newer version of the file dialog that is compatible with RAP 1.4. This update fixes the problem with missing file names mentioned in the comments.

分享到:
评论

相关推荐

    file-uploading-with-php-and-mysql.rar_file upload_truth5fw

    标题中的“file-uploading-with-php-and-mysql.rar_file upload_truth5fw”暗示了这是一个关于使用PHP和MySQL实现文件上传功能的教程或代码示例。PHP是一种广泛使用的服务器端脚本语言,尤其适合Web开发,而MySQL是...

    Uploading and Viewing Files the Easy Way

    "Uploading and Viewing Files the Easy Way" 这个主题聚焦于简化这一过程的技术和最佳实践。我们将探讨如何实现高效、安全且用户体验良好的文件上传与查看功能。 首先,上传功能的核心在于前端和后端的交互。前端...

    RadControls.for.ASP.NET2.Q1.2007.SP2.RadUpload.Net2.v2.3.2.0

    a highly efficient proprietary HttpModule, which enables uploading of files with size up to 2GB, while allocating a minimum amount of server memory. UI control for single- and multi-file uploads, ...

    Uploading and Downloading Files in Web Dynpro Java

    ### SAP NetWeaver 04 Web Dynpro Java:文件上传与下载 #### 一、概述 在企业级应用开发中,文件的上传与下载是非常常见的功能需求之一。特别是在使用SAP NetWeaver 04平台进行开发时,利用Web Dynpro Java框架...

    file-uploading-with-activestorage

    自述文件该自述文件通常会记录启动和运行应用程序所需的所有步骤。 您可能要讲的内容: Ruby版本系统依赖配置数据库创建数据库初始化如何运行测试套件服务(作业队列,缓存服务器,搜索引擎等) 部署说明...

    revit-ifc-master.zip

    • BIM Master provides users free Cloud storage•By uploading files through web, files are saved in your Cloud storage, you can access files from mobile devices •Once you make any changes on your ...

    化妆品培训材料.pptx.baiduyun.uploading.cfg

    化妆品培训材料.pptx.baiduyun.uploading.cfg

    Uploading Desktop

    Uploading Desktop

    KCFinder|CKEditor的文件管理器 v2.5.1 多国语言版.zip

    02 Select multiple files with the Ctrl/Command key 03 Download multiple files or a folder as single ZIP file 04 Clipboard for copying and moving multiple files 05 Easy to integrate and configure in...

    化妆品工艺.pptx.baiduyun.uploading.cfg

    化妆品工艺.pptx.baiduyun.uploading.cfg

    django+ajaxfileupload文件上传demo

    from django.core.files.storage import default_storage def upload_file(request): if request.method == 'POST' and request.FILES['file']: file = request.FILES['file'] filename = default_storage.save...

    gs-uploading-files:上载档案

    目录 ... 你会建立什么 您将创建一个接受文件上传的Spring Boot Web应用程序。... 你需要什么 从Spring Initializr开始 如果使用Maven,请访问Spring Initializr以生成具有所需依赖项(Spring Web和Thymeleaf)的新项目...

    Beginning PHP and MySQL 5:From Novice to Professional

    Provides over 500 code examples, including real-world tasks such as creating an auto-login feature, sending HTML-formatted e-mail, testing password guessability, and uploading files via a web ...

    CuteFTP 8 Professional

    Uploading files to remote pane by right-clicking the files in Windows shell. Subscribing to media files and publishing media files using the CutePODCast Manager. Finding files and folders using the ...

    PHP经典教程 PHP 5 Fast & Easy Web Development

    Chapter 10 - Uploading Files to Your Website Part IV - Getting to Know Your MySQL Database Chapter 11 - Establishing a Connection and Poking Around Chapter 12 - Creating a Database Table ...

    Catalyst socket tools v6

    Using SocketTools, you can easily add features such as uploading and downloading files, sending and retrieving e-mail, exchanging information with web servers, interactive terminal sessions and ...

    wsoshell:WSO WebShell

    • View, hexview, editing, downloading, uploading files • Working with zip archives (packing, unpacking) + compression tar.gz • Console • SQL Manager (MySql, PostgreSql) • Execute PHP code • Wo

    Beamyfile:lulea 大学动态 Web 系统设计项目的存储库 - M7011E

    Homepage for uploading files (IDEA AND "TODO") User login Able to chat with other logged in users upon request (group or "1v1"). Able to upload files to user-collection (can be private or public ...

Global site tag (gtag.js) - Google Analytics