TOPIC File Upload is an experimental web protocol (RFC 1867) that allows web browsers to upload a file to the server. Integrating this with WebObjects is non-trivial, because it involves supporting a new form type. This article contains sample code demonstrating how to implement File Upload under WebObjects 3.1 or 3.5.1. File Upload capability is supported natively in WebObjects 4; see the WebObjects 4 documentation for more information. DISCUSSION Disclaimer The source code provided in this example is not supported by Apple Enterprise Software. Apple disclaims any warranty of any kind, expressed or implied, as to its fitness for any particular use Installation The example can be downloaded by anonymous FTP at the following address: ftp://ftp.info.apple.com/Apple_Support_Area/Apple_Software_Updates/MultiCountry/Enterprise/webobjects/examples/File_Upload_Example.compressed On mach, simply double-click on this file and the Workspace will unpack it to FileUpload.woa . On NT, you must rename the file to FileUpload.tar.Z . At the DOS prompt, type: gunzip FileUpload.tar.Z tar xvf FileUpload.tar Post-Installation Instructions (WebObjects 3.5.1 only) This example was originally written for WebObjects 3.0 and 3.1. To use it with WebObjects 3.5.1 on Solaris or Windows NT, you will need to make a few changes to the installed files: WebObjects 3.5.1 Solaris On Solaris, you will need to open the WoUtilities.h file that is a part of the example and change one reference to NeXT_DOLE to read NeXT_PDO . The line you need to change will look like this: #if (NS_TARGET_MAJOR == 4 || NeXT_DOLE || WIN32) Replace NeXT_DOLE with NeXT_PDO in this line. The corrected version of this line is: #if (NS_TARGET_MAJOR == 4 || NeXT_PDO || WIN32) WebObjects 3.5.1 NT On Windows NT, there are three things you need to do to get the example to compile and run under OpenStep 4.2. 1) In the NSDataUtils.m file that is a part of the example, comment out the import of libc.h and memory.h 2) In the same file, create a memcmp() function. To do this, simply copy the memscasecmp() function, and delete the first two "if" statements (the first four lines of code). 3) In the FileUpload.wos file, replace " uploadedFileContents " with " fileContents " and " uploadedFileName " with " fileName ". Notes · You must modify an application's main file to use RequesterApplication. The RequesterApplication uses MultipartRequest to handle its requests · The results of the file upload are stored in FileUpload's bindings filename and fileContents . filename is the name of the file on the client's side. fileContents is an NSData containing the file. To write the data to a file, use [NSData writeToFile:atomically:] . This is what is done in FileUpload.wo 's script · File upload is server independent, but it is browser dependent. It has been tested with Netscape and OmniWeb |
Document Information | |
Product Area: | WebObjects |
Category: | WebObjects 3.0 and 3.1; WebObjects 3.5.1 |
Sub Category: | Examples; Examples |
Copyright © 2000 Apple Computer, Inc. All rights reserved.