Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

@Retention(CLASS) @Target({PARAMETER})

public @interface RequestPart

Binds one part of a multipart/form-data request body to this parameter.

@PostMapping("/avatar")
public String upload(@RequestPart("file") HttpServer.Part file) {
    store(file.getFilename(), file.getBytes());
    return "stored " + file.getSize() + " bytes";
}

The parameter is a com.codename1.backend.HttpServer.Part – name, filename, content type and bytes – or byte[] for the content alone, or String for a text field. A body that is not well-formed multipart is answered 400 before the method runs, as is a missing required part.

Methods

public abstract String value()The part’s name, from its Content-Disposition.
public abstract boolean required() default trueWhether a request without the part is rejected.

Method details

value

public abstract String value()
The part’s name, from its Content-Disposition. Required for the same reason RequestParam’s is: a parameter’s own name does not survive compilation.

required

public abstract boolean required() default true
Whether a request without the part is rejected.