Media Plugins Upload
In this section we'll further drill into media upload and error handling in Ricos.
#
Upload Functions APIThis functions should be passed to the media plugins via config \ helpers (i.e image, gallery, video , audio and file upload).
handleFileUpload
is a function provided to handle media uploads from the native file input.
handleFileSelection
is a function provided to handle media uploads from a custom file input.
In both functions when the upload phase is done the updateEntity
callback should be called with an object containing the data, error (upon faliure) and index (for multiple file uploads).
data
schemes#
Media Plugins #
Image and Gallery#
Video#
Audio#
File Upload#
ErrorsIn order to take advantage of Ricos stunning error toasts and general error handling a proper error
object of type MediaUploadError
should be passed.
Passing an error object triggers a toast indicating what caused the upload to fail as well as an indication of the error on the block.
Using the getContent
method of RicosEditor would also remove all blocks with errors from the content, thus they won't be seen on Viewer nor saved.
msg
is a simple string or JSX Element to use for custom error messages to be displayed.
key
is an enum with our built in supported and localized error types.
args
are arguments needed for the built in toasts.
GENERIC
a general error with no specific reason
SIZE_LIMIT
the file is too big to upload, supports an argument maxLimit
for maximum file size indication.
QUOTA_STORAGE_VISITOR
file storage exceeded the limit (UoU).
QUOTA_STORAGE_OWNER
file storage exceeded the limit (User), supports an argument upgradeUrl
to upgrade the site's plan.
QUOTA_VIDEO_VISITOR
video hours on the site have reached the maximum (UoU).
QUOTA_VIDEO_OWNER
video hours on the site have reached the maximum (User), supports an argument upgradeUrl
to upgrade the site's plan.