realbasic

FGUpload: A Better Real Studio WebFileUploader

I recently purchased a new license for Real Studio Web Edition as I have an idea for a web app that I’ve been meaning to build for quite some time. The app in mind will require the uploading of multiple image files of various sizes to the server. Whilst mocking up the uploading interface with the excellent Balsamiq Mockups tool I thought I had better quickly explore the file uploading controls available in Web Edition. I was frankly horrified by the lack of functionality of the only file uploading control available to Web Edition – the WebFileUploader.

The native WebFileUploader has several limitations:

  1. Ugly UI.  You are essentially stuck with a listbox with two buttons, “+” and”-”
  2. No events to inform of the live progress of uploads
  3. No information on file size
  4. No drag and drop support
  5. File sizes are limited as the entire file is written to the RAM of your server

Almost all of these limitations were show stoppers for my nascent project and I needed a workaround.  Searching on the forums and through feedback reports revealed many other people with the same complaints but it seems that RS is aware of the limitations but can’t rectify things without changing the underlying HTTP framework.

I did some research and came across a Javascript plugin / library called Plupload which provides a framework for uploading files to a server using a combination of javascript and PHP.  It uses several runtimes to achieve this and will gracefully look for whatever runtime is available on the browser (either Flash, Silverlight, Google Gears, HTML 5 or good old HTML 4).

After a lot of tinkering / reading and swearing, I have managed to get a nice working framework to incorporate Plupload into your web apps and I thought I’d share the code and steps required to do this. I call the framework – FGUpload.

Summary
Firstly, download the required files.

Within your web app, instead of the user clicking on a WebFileUploader control you present them with an appropriately sized WebHTMLViewer (I find using a modal dialog works well).  The WebHTMLViewer points to a URL which contains Plupload.  The user interacts with Plupload through the WebHTMLViewer (of course they don’t realise this, they think they are still within your web app) and upload the files they want.  Once the upload is complete, Plupload redirects the user to a special URL which is handled by the App.HandleSpecialURL() event.

First of all, upload the entire contents of the [UPLOAD CONTENTS TO SERVER] folder to the server location of your choosing.  Next, within the FGUpload Real Studio project, change the value of dlgUpload.UploadURL to the URL of the uploaded index.html file.

The URL that the WebHTMLViewer points to is the location of the Plupload installation (index.html within the included folder).  Appended to this URL is a single parameter (id) containing the session identifier.  For example, if the URL of your Plupload installation is www.example.com/upload.html and the session identifier is ABCDEF123, the WebHTMLViewer.URL property should be: www.example.com/upload.html?id=ABCDEF123.

You need to edit the index.html file within the download specifying the URL of your web app.  Set the variable ‘webapp_url‘ to the URL of your web app (it’s near the top of the file).  In the example, it’s set up for local debugging. Within index.html, there is a line that says: unique_names : false.  By default, Plupload will leave the filename of uploads alone but you can set this to true to have it rename them to a unique name.  The reason this is false by default is that I haven’t (yet) figured out a way to get the new name of the file.

Finally, you may want to edit the included upload.php file to specify the folder that uploaded files should be saved.  The line to change is $targetdir = ‘uploads’;

When Plupload has completed uploading the selected files, it will redirect the WebHTMLViewer to webapp_url/special/upload and pass several parameters.  The first parameter is id and this contains the ID of the session that called Plupload.  Subsequent parameters are the names of the files uploaded.  E.g: mywebapp.com/special/upload?id=ABCDEF123&name0=pic1.jpg&name1=anotherpic.png.

There’s a lot more that can be done by tinkering with this and this is far from a completely functional application but it should serve an illustrative purpose.  Please let my know your thoughts in the comments.

Real Software’s Roadmap

This post is in response to Bob Keeney’s open letter to RS which has garnered quite a few comments.

There are three issues here that I can see:

  1. The rapid release model
  2. The time RS devotes to bug fixes
  3. The new IDE

First of all let’s get it out there, I like the rapid release model (RRM).  What I don’t like, however, is Real Software’s implementation of it. To quote the RS support page:

once a product is released, a new version is released on the Internet every 90 days

In principle, this is a great idea.  Customers win as RS pushes out new features and bug fixes as and when they’re ready and RS wins as it’s customers upgrade more frequently as they plenty of active development in the tool.

Only this isn’t what happens. The last time RS released an update (2011 release 4) was 5th December 2011. By my calculations, that’s exactly 140 days ago. Even if they release 2012 r1 today, are they going to offer existing license holders a 50 day extension to their licenses? I doubt it.

It’s been a long running (non) joke for years now that RS prioritise new features over bug fixes. There is plenty of evidence to support this from bug reports I’ve supported alone (13 months old, 16 months old, 9 months old).  All of these bugs have been Cocoa show stoppers for me and they are basic UI issues (I mean honestly, no focus ring around text fields?). Some of these have been marked as verified a year ago and yet have not been fixed – lost to the ether I suspect. Adding new features will not attract sustainable customers. Sure, new customers might come along but they won’t stay if the product is unreliable or they see that bugs are being ignored for years.

Finally we come to the new IDE.  I haven’t seen it. RS posted a teaser about it back in January but there have been no updates about its progress since although we know that it’s coming in 2012 release 1 (whenever that arrives). I think a redesign probably is in order, largely because there have been several user interface advances in recent years and implementing them may improve my productivity.  My worry, however, is that RS are updating the UI to attract new customers, not to improve the experience for existing license holders. If they wanted to improve my experience, they could simply fix my bugs.

I really love Realbasic as a programming language.  I can create things with it that I’m simply not able to do with Objective-C or .NET or Java with my current level of knowledge.  I just dislike the company who I’m dependent upon as a developer because I feel out of the loop and not listened to.

 Scroll to top