Interface

SimpleUploadConfig (upload)

@ckeditor/ckeditor5-upload/src/uploadconfig

interface

The configuration of the simple upload adapter.

ClassicEditor
	.create( editorElement, {
		simpleUpload: {
			// The URL the images are uploaded to.
			uploadUrl: 'http://example.com',

			// Headers sent along with the XMLHttpRequest to the upload server.
			headers: {
				...
			}
		}
	} );
	.then( ... )
	.catch( ... );

See the "Simple upload adapter" guide to learn more.

See all editor configuration options.

Filtering

Properties

  • headers : Record<string, string> | ( File ) => Record<string, string> | undefined

    Headers sent with the request to the server during the upload. This is the right place to implement security mechanisms like authentication and CSRF protection.

    The value can be specified either as an object of key-value pairs or a callback function that returns such an object:

    ClassicEditor
    	.create( editorElement, {
    		simpleUpload: {
    			// Set headers statically:
    			headers: {
    				'X-CSRF-TOKEN': 'CSRF-Token',
    				Authorization: 'Bearer <JSON Web Token>'
    			}
    
    			// Or dynamically, based on the file:
    			headers: ( file ) => {
    				return {
    					'X-File-Name': file.name,
    					'X-File-Size': file.size
    				};
    			}
    		}
    	} );
    

    Learn more about the server application requirements in the "Server-side configuration" section of the feature guide.

  • uploadUrl : string

    The path (URL) to the server (application) which handles the file upload. When specified, enables the automatic upload of resources (images) inserted into the editor content.

    Learn more about the server application requirements in the "Server-side configuration" section of the feature guide.

  • withCredentials : boolean | undefined

    This flag enables the withCredentials property of the request sent to the server during the upload. It affects cross-site requests only and, for instance, allows credentials such as cookies to be sent along with the request.

    ClassicEditor
    	.create( editorElement, {
    		simpleUpload: {
    			withCredentials: true
    		}
    	} );
    	.then( ... )
    	.catch( ... );
    

    Learn more about the server application requirements in the "Server-side configuration" section of the feature guide.

    Defaults to false