add Attachment
Adds a new attachment to this AttachmentsFormElement from the specified file.
The attachment name is provided by the name parameter. When useOriginalFilename is true the provided value will be used, but when useOriginalFilename is false the name parameter is ignored and one is generated automatically instead.
FileNotFoundException will be set if the file does not exist.
MaxAttachmentCountConstraintException will be set if adding this attachment would exceed the maximum number of attachments allowed.
MaxAttachmentDurationConstraintException will be set if the attachment exceeds the maximum duration specified by AudioFormInput.maxDuration or VideoFormInput.maxDuration.
MaxAttachmentSizeConstraintException will be set if the attachment exceeds the maximum size specified by DocumentFormInput.maxFileSize.
IncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed AttachmentsFormInputType.
Return
A Result containing the new FormAttachment.
Since
300.0.0
Parameters
The attachment name.
The type of content.
Path to a file that will be used for the attachment's content.
Adds a new attachment to this AttachmentsFormElement.
The name parameter is optional. If omitted, an attachment name is generated automatically. If name is provided and useOriginalFilename is true, it is used as the attachment name. If useOriginalFilename is false, name is ignored and an attachment name is generated automatically.
If the attachment is an image and it exceeds the maximum size specified by ImageFormInput.maxImageSize, it will be resized to meet that requirement before being added.
MaxAttachmentCountConstraintException will be set if adding this attachment would exceed the maximum number of attachments allowed.
MaxAttachmentDurationConstraintException will be set if the attachment exceeds the maximum duration specified by AudioFormInput.maxDuration or VideoFormInput.maxDuration.
MaxAttachmentSizeConstraintException will be set if the attachment exceeds the maximum size specified by DocumentFormInput.maxFileSize.
IncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed AttachmentsFormInputType.
IllegalStateException will be set if the provided data is empty.
Return
A Result containing the new FormAttachment.
Since
300.1.0
Parameters
The type of content.
The attachment data.
The attachment name.
Adds a new attachment to this AttachmentsFormElement from the specified file.
The attachment name is generated automatically. When you wish to provide a custom name and useOriginalFilename is true, use the overload of this method that takes a name parameter.
If the attachment is an image and it exceeds the maximum size specified by ImageFormInput.maxImageSize, it will be resized to meet that requirement before being added.
FileNotFoundException will be set if the file does not exist.
MaxAttachmentCountConstraintException will be set if adding this attachment would exceed the maximum number of attachments allowed.
MaxAttachmentDurationConstraintException will be set if the attachment exceeds the maximum duration specified by AudioFormInput.maxDuration or VideoFormInput.maxDuration.
MaxAttachmentSizeConstraintException will be set if the attachment exceeds the maximum size specified by DocumentFormInput.maxFileSize.
IncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed AttachmentsFormInputType.
Return
A Result containing the new FormAttachment.
Since
300.1.0
Parameters
The type of content.
Path to a file that will be used for the attachment's content.
Deprecated
Since 300.0.0. This method will not validate the duration of audio and video attachments. Use the suspend function addAttachment(contentType: String, data: ByteArray, name: String? = null) instead.
Replace with
addAttachment(contentType, data, name)Adds a new attachment to this AttachmentsFormElement.
Return
The new FormAttachment.
Since
200.5.0
Parameters
the name of the attachment
the mime type of the attachment
the attachment data
Throws
if data is empty