UploadAdapter (upload)
@ckeditor/ckeditor5-upload/src/filerepository
Upload adapter interface used by the file repository to handle file upload. An upload adapter is a bridge between the editor and server that handles file uploads. It should contain a logic necessary to initiate an upload process and monitor its progress.
Learn how to develop your own upload adapter for CKEditor 5 in the "Custom upload adapter" guide.
Filtering
Methods
-
abort()
module:upload/filerepository~UploadAdapter#abort
Aborts the upload process. After aborting it should reject promise returned from upload().
Take a look at example Adapter implementation and createUploadAdapter method.
-
upload() → Promise.<Object>
module:upload/filerepository~UploadAdapter#upload
Executes the upload process. This method should return a promise that will resolve when data will be uploaded to server. Promise should be resolved with an object containing information about uploaded file:
{ default: 'http://server/default-size.image.png' }
Additionally, other image sizes can be provided:
{ default: 'http://server/default-size.image.png', '160': 'http://server/size-160.image.png', '500': 'http://server/size-500.image.png', '1000': 'http://server/size-1000.image.png', '1052': 'http://server/default-size.image.png' }
You can also pass additional properties from the server. In this case you need to wrap URLs in the
urls
object and pass additional properties along theurls
property.{ myCustomProperty: 'foo', urls: { default: 'http://server/default-size.image.png', '160': 'http://server/size-160.image.png', '500': 'http://server/size-500.image.png', '1000': 'http://server/size-1000.image.png', '1052': 'http://server/default-size.image.png' } }
NOTE: When returning multiple images, the widest returned one should equal the default one. It is essential to correctly set
width
attribute of the image. See this discussion: https://github.com/ckeditor/ckeditor5-easy-image/issues/4 for more information.Take a look at example Adapter implementation and createUploadAdapter method.
Returns
Promise.<Object>
Promise that should be resolved when data is uploaded.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.