Skip to content

PLIP: TUS reliable large uploads with simpler file upload UI in volto and better feedback on slow connections #5423

Description

@djay

PLIP (Plone Improvement Proposal)

Abstract

This PLIP has three aims (and could be separated if desired)

  • Implement TUS in volto for "contents > upload" with a UI similar to quanta design (inc progress bars)
    • pick a js tus client to use in core
    • brings parity with classic
    • a UI that gives feedback on progress when files are large (even without TUS)
    • bring UI closer to Quanta roadmap
  • Implement TUS uploads when editing files, ie TUS support for any dexterrity content type with file fields and for images/videos fields in blocks
    • otherwise its hard to explain that large uploads can only be done via content > uploads
  • Simplify new file object creation UI by replacing "Add > File" with "Add > Upload files" (as per quanta design)
    • because File objects are not an obvious way to add files
  • Add a mode for TUS via restapi that doesn't require a shared temp folder so we can have single implementation and UI that requires less maintenance. (@davisagli suggestion)

Context

  • Classic had only support for TUS in the contents file upload. This seems to be currently broken?

Motivation

  • As an installer I can enable optional TUS support to enable large uploads and choose chunk size and temp folder to suit deployment but UX for the editors mostly the same
  • As an editor it should be obvious and quick to bulk upload files
  • As an editor, if the connection is slow or intermittent I should have clear indications upload is working, and options to resume if upload was not successful and this should apply to all places in the UI I can upload a file including editing a file object or in blocks.
  • As Ops, I can enable POST size limits and still allow larger uploads.

Assumptions

  • TUS requires more complex installation so will be turned off unless installer knows what they are doing
  • Folder contents > upload is a currently “hidden feature”
  • Add > File is too many clicks for most people and it’s not obvious the title is optional

Proposal & Implementation

TUS for contents upload

  • enabled by env variables
    • frontend TUS support will be enabled with TUS_CHUNK_SIZE and TUS_TMP_FILE_DIR environment variable
      • otherwise file will be sent as a whole and TUS "create with upload" api call since there is no guarantee the tmp dir will be the same between requests.
  • propose to use tus-js-client and semantic UI.
  • code will be borrowed for two existing attempts. Both branches replace the only contents upload page

TUS for file fields/blocks

  • no current branch but rough plan
  • would likely do upload when save button clicked
    • preserve transactional integrity and less likely to leave partial files around
    • OR - upload as soon as file is picked but don’t do the final step to move into a blob until save
      • need to check if this is possible. - pass in the uid of the upload and have the backend do the final step.
      • cancel will need to remove temp files
      • pro:
        • big upload can finish while user fills out rest of form.
      • con:
        • more likely to be abandoned temp files so more clean up?
        • validation won't happen until save so large files files or "bad" files could be uploaded to tmp.

Replace Add > File

  • Replace "Add > File” with “Add > Upload files” and the get bulk upload page
  • Any special file based content type e.g. Video, would still appear in Add menu
    • but could have control panel option to hide them?
  • Upload files would create content types based on file extensions and contenttype, so won’t always be “File” content type.
  • image

UI for "upload files"

  • propose to make similar to quanta (but with semantic)

    • image
    • page not a modal
    • page has no theme footer header etc
    • Put uploaded elements above dropzone. makes more logical sense that adding adds to the end of the list
    • Put title of: Upload to "test" to give more context so users more sure of where they are uploading
    • Include image preview
  • Additional things not specified in quanta design

    • Visually indicate on the dropzone when hovered over
    • "Back" instead of "Save" and "Cancel"
      • quanta design has save and cancel buttons which imply uploads happens only when you click save
      • instead we propose upload as soon as you select file and replace save and cancel with "back" button
      • Once single file uploaded there is a "delete" button to delete that single file (next to last modified date)
    • progress bar and overall status
      • during upload progress bar and cancel button replaces last modified date in quanta design. once complete "last modified date" and delete button.
      • current pretagov UI
        • image
      • designed to show upload is not hung even if its slow
        • progress bar is too small to show movement for slow connection, so bytes below helps as well as estimate that keeps changing.
    • retry button
      • if upload fails, retry button appears so upload is resumed/restarted without having to reselect file
      • replaces last modified date
    • return to "uploaded" page.
      • Nice to have: user can click on uploaded file, edit, then use back button to get to upload page again and still be shown the same list of uploaded files.
      • allows bulk editing/renaming after bulk upload
    • Any validation error for a file (from DX) or other error will display next to the row with an indication this file hasn't been uploaded.
    • Preview - done client side or after file created?

TUS without temp folder

  • use ZODB blobs to store partial uploads and then join them at the end
    • This will have the tradeoff of using double the space until packing occurs but setting up a temp file will avoid this
    • we could also set the default chunk size to be very large so as to avoid additional storage being needed in most cases?

Deliverables

  • create PR "upload view always using TUS and showing large file progress"
    • Take pretagov branch and replace uploady with tus-js-client
    • Change restapi to only accept "creation with upload" api call when no tus temp dir is defined and change frontend to check which way it should upload. means TUS client is always used even for simple plone deployments
    • remove old upload code not using TUS
    • Add env var to set max CHUNK size
    • tests?
    • Document deployment including TUS temp folder to enable resuming and chunked uploads for slow connections.

Additional work

  • rearrange upload page layout to be closer to quanta layout. move out of overlay.
  • create PR for replacing "add file" with "upload files"
  • submit PR for "large/TUS file support in all volto"
    • develop replacement volto file component that works with TUS and won't finish transaction until save
    • replace all file uploads in the volto UI
    • replace inline uploads like video and image blocks

Risks

OK/Cancel for "upload files"? ie finish upload/transactions when click save, not after picking.

  • preview would have to be done client side
  • Pro:
    • lets you change your mind about upload before a db transaction happens.
    • could allow you to edit title or other metadata before you upload?
  • con:
    • UI would work differently when TUS is turned off. files either have to be uploaded on save button or objects created directly after upload without TUS since its not a two step process.
    • user might not realise they need to click save otherwise upload is lost
    • last step can take a long time depending on how the serverside is arranged (if tmp and blobs on seperate disks or blobs stored in the DB). Would there need to be an additional progress for this?

Size of bundle with extra lib

  • it's pretty small and its easier to maintain if all the code uses the same method client code to do uploads.

File Widget

  • upload on save vs upload on pick. which works best?

Participants

Context

Related optimisation on the backend to speed up the last part of a large upload

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions