Rop File Upload Solution ideas

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.