Because the service request message is a text that cannot be transmitted directly to the binary file content, it is necessary to use some kind of
The conversion mechanism converts the binary file content to a string. Rop uses the following methods to encode the uploaded files:
<filetype>@<base64 (file contents) >
<fileType> represents the file type, the file content is encoded using the BASE64 algorithm, so that the binary file
The content can be converted to a string, separated by the "@" character. After the server receives the uploaded file, it can
Resolves the type of file and the contents of the file.
Rop defines a uploadfile that represents an uploaded file and looks at the definition of UploadFile:
Packagecom.rop.request;Importcom.rop.annotation.IgnoreSign;Importorg.springframework.util.FileCopyUtils;ImportJava.io.File;Importjava.io.IOException, @IgnoreSign ① Public classUploadFile {PrivateString FileType; Private byte[] content; PublicUploadFile (String FileType,byte[] content) { This. Content =content; This. FileType =FileType; } Publicuploadfile (file file) {Try{ This. Content =Filecopyutils.copytobytearray (file); This. FileType = File.getname (). substring (File.getname (). LastIndexOf ('. ') +1); } Catch(IOException e) {Throw NewRuntimeException (e); }} PublicString Getfiletype () {returnFileType; } Public byte[] getcontent () {returncontent; }}
Rop File Upload Solution ideas