File Upload - Amazon S3 Storage or Alpha Anywhere Server

Description

Upload one or more files to Amazon S3 or to the Alpha Anywhere server.

Used with the UX component.

 Target Server Properties

Upload target

Specify the target server to which files should be uploaded. You can upload to Amazon S3, or the Alpha Anywhere server. Choices include S3, AlphaAnywhere.

Xbasic function

Specify the name of the Xbasic function to call once each file has been uploaded.

Additional info to submit - Javascript

Specify the Javascript to execute to collect any information from the client-side that you want to make availalbe to the Xbasic function. Your code should return a string (which could be the stringified version of a Javascript object). The data returned by this function will be available in the Xbasic function in a property called 'e.__additionalInfo'.

 File Selection Properties

Method for selecting files

Specify if the user can select the file(s) to be uploaded, or if the data for the file to be uploaded will be supplied (in the form of a base64 encoded string -- that is formatted as a 'data URI' e.g. data:image/jpeg;base64,/sjsakjjs....). Choices include User selects file(s), Base64Data.

Javascript function to get base64 encoded data

Specify the name of the Javascript function that will return the base64 encoded data to be uploaded. Returned base64 data is expected to be in data URI format. e.g. data:image/jpeg;base64,/skaakjfhaksdfh......

 Amazon S3 File Upload Properties Properties

Method for specifying Amazon S3 credentials and bucket

Should the Amazon S3 credentials and bucket be read from a named storage connection string, or do you want to specify explicit values for the access key, secret and bucket. Choices include Named Storage Connection String, Explicit.

Storage connection string

Specify the named storage connection string. IMPORTANT: The storage connection string MUST NOT BE ENCRYPTED. TIP: To define a storage connection string, go to the Tools menu in the Web Projects Control Panel.

Access key

Specify the access key.

Secret

Specify the secret.

Bucket

Specify the bucket.

Authenticated read

Specify if authentication is required to read the object once it has been uploaded to S3

S3 Timeout

Specify the S3 timeout in milliseconds. This is the amount of time allowed before authorization to upload files to S3 will expire. If you have a lot of files to upload, you may want to increase this value. Suggested value is 600.

 Validation Properties

Allow mutiple files

Specify if the user can upload multiple files at once, or just a single file.

Maximum file size

Specify the maximum size file that the user can select. Set to -1 for no maximum.

Max file size exceeded error message

Specify message to show if user selects a file that is too big. You can use language or text dictionary tags. Your message can include these placeholders: [filename], [filesize], [maxfilesize]. Leave blank if you have defined a custom Javascript onValidate event handler.

Max total file size

Specify the maximum total size of all selected files. Set to -1 for no maximum.

Max total file size exceeded error message

Specify message to show if all files selected exceed the max allowed. You can use language or text dictionary tags. Your message can include these placeholders: [filecount], [totalfilesize] and [maxtotalfilesize]. Leave blank if you have defined a custom Javascript onValidate event handler.

Allowed file types

Enter a comma delimited list of allowed file extensions. Leave blank to allow all file extentions.

Invalid file type error message

Specify message to show if all files selected exceed the max allowed. You can use language or text dictionary tags. Your message can include these placeholders: [filename], [filetype]. Leave blank if you have defined a custom Javascript onValidate event handler.

Display progress during file upload

Specify if progress should be shown while file(s) are being uploaded.

Allow cancel

Specify if the user can cancel an upload while the file is being uploaded.

Progress indicator type

Specify the progress indicator style. 'Text' - display the percentage as text, 'Bar' - display a progress bar. Choices include Text, Bar.

Progress bar color

Specify the progress bar color.

Progress bar width

Specify the progress bar width. Use CSS units.

Placeholder for progress indicator

Specify the name of a Placeholder control where the progress indicator should be shown.

 Javascript Properties

Target object name on Amazon S3

You can define a function that returns the name of the object in Amazon S3. By default, the filename of the file on the client will be used. Your code can reference e.name, e.size and e.type (the client-side name, size and mime-type of the selected file). Your function must return the name to use. The name can include a folder. For example: return 'myfolder1/' + e.name. This will use the same name as the client-side file but the object will be stored in a folder called 'myfolder1'. NOTE: The target name on Amazon will be available to other Javascript functions in the e.targetName property.

Before file select

Fires before the user selects file(s). If the Javascript contains 'return false;', the file upload is aborted.

After file select

Fires after file(s) have been selected, but before any files have been uploaded. If your code includes 'return false' the upload is aborted. You code can reference 'e' - an array of objects with information about each file selected. Each item in the array contains these properties: name, size, type.

On Progress

Fires when another 'chunk' of the file being uploaded has been sent. This event allows you to write custom progress displays. Your code can reference these variables: e.percent - percentage complete, e.message - message describing the current state of the upload operation, e.name - name of the file being uploaded, e.number - if more than one file was selected, the number of file, e.size - the file size and e.type - the mime-type of the file, e.targetName - the name to use on Amazon to store the file (usually the same as e.name unless your 'Target name on Amazon S3' function returned a different name or specified a folder)

On Error

Fires if there is any type of error. Your Javascript can reference e.errorText, e.errorCode - the XHR error code and e.fileObject - an object with properties (such as name, size, type) for the file on which the error occured.

On Upload Complete - Individual File

Fires after a file upload has been completed. This event will fire for each individual file this is uploaded and the 'On Upload Complete - All Files' event will fire after all files have been uploaded. Your code can reference this variables: e.name - name of the file just uploaded, e.type - mime-type, e.aborted - true if the user cancelled, e.size - file size, e.number - if more than one file was uploaded, the number of the file and and e.targetName - the name to use on Amazon to store the file (usually the same as e.name unless your 'Target name on Amazon S3' function returned a different name or specified a folder).

On Upload Complete - All Files

Fires after all selected files have been uploaded. You code can reference e.fileArray - an array of objects containing information about each file that was uploaded. Each item in the array has these properties, name, size, type,aborted, targetName (name used on Amazon - same as name unless you specified a different name).

On Upload Complete

Fires after the selected file has been uploaded. Your code can reference this variables: e.name - name of the file just uploaded,e.aborted - did the user abort the upload, e.type - mime-type, e.size - file size, e.targetName - name used on Amazon.

On validate error

Fires if any of the selected files violate a validation rule. Your Javascript can refer to e.violationType ( can be 'size', 'totalSize' or 'type'), e.name, e.size and e.type.

See Also