Designing file upload solutions

Some solutions can just use File package types to upload and manage files. However, if the files are closely integrated into the solution, you need to think about a number of factors:

Attachment

When you upload a file, do you want to attach the file node as a member target? You need to do this if the individual file is part of the data (e.g. "attach documentary evidence", or "upload profile photo"). You don't need to do this if you are just uploading files that you will reference later, or if a whole collection of files makes up the data.

If you want to attach a file node you should upload the file in the edit view of the node that is going to attach to the file. You also need to allow for the user attaching a file that they have uploaded elsewhere.

If you do not want to attach the file node, you should design the solution to have a package of uploaded files, and upload the file directly into the package.

You can use member types created with Upload Member Type and Gallery Member Type to upload, attach and display image files. If you want to use the gallery member type in edit view and need to attach the images to a member type other than the gallery member type, use derivation to copy from the gallery member type to the other member type.

Storage

If you want to attach the file, you need to think where you want to store the uploaded files. There are three options:

  • Store the uploaded file using the attaching node as the package.
  • Store the uploaded file in the same package as attaching node.
  • Store the file in a package identified by a binding reference, which will be evaluated from the attaching node.

In many cases, storing the uploaded file using the attaching node as the package is the most convenient. However, you do need to consider permissions to access the package, probably using a combination of a Permission Manager and a Permission Manager Updater.

If you do not want to attach the file, it usually makes sense to store the files using the node that has the upload control as a package.

Browse or edit

If you want to attach the file, it makes sense to present the upload as part of the node edit. This means that only people with edit authority can attach the files, which is what you want.

If you do not need to attach the file, it usually makes sense to upload files in browse view. However, if the files that you upload are used in edit view (for example, uploaded images within a page), then it can make more sense to upload files in edit view.

Image files

Image files can be uploaded like any other files. However, the File With Derivatives type allows you to:

  • Control the size, format and quality of the uploaded file.
  • Create derivative files, such as thumbnail views.
  • Store the original, unaltered file, as well as other size versions.

If you do use this feature, you need to consider where to store the derivative files. This is similar to the storage of the main file: you can store derivatives using the main file as the package, in the same package as the main file, or in a package identified by a binding reference which will be evaluated from the main file.

Display

Consider how you want to display the files.

The main options are:

  • Just list the files as targets.
  • Use a gallery member type created by Gallery Member Type.
  • Show as a table, using File View, or a view that contains some of the same column scripts.

For an unattached file, it usually makes sense to show either a table or a gallery.