A document online preview and download method based on microservice architecture
Through a method based on microservice architecture, VUE and axios are used for file upload and processing, and OpenOffice and PDFJS plug-ins are combined to realize online document preview and download, which solves the problem of document preview on devices that do not support Flash, simplifies user operations and enhances security. manage.
Patent Information
- Application Number
- CN202111640031.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-12-29
AI Technical Summary
Online preview of existing documents cannot be used normally on Android devices that do not support Flash playback function, and users need to perform cumbersome downloading and opening file operations, affecting user experience and permission management.
Using a method based on microservice architecture, files are uploaded through VUE encapsulation components, axios is used to call the back-end API for file processing, and documents are previewed and downloaded online through OpenOffice and PDFJS plug-ins, supporting segmented uploads and security permission control.
It realizes the online preview and download function of documents on devices that do not support Flash, simplifies user operations, enhances user experience and permission management, supports online preview and download of files in multiple formats, and ensures the safe management of corporate documents.
Smart Images

Figure CN114330231B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information system software technology, and in particular to a document online preview and download method based on a microservice architecture. Background Art
[0002] Currently, most online document previews are implemented with the help of browsers and Flash plug-ins. They cannot be used on Android devices that do not support Flash playback. They require the use of third-party Flash browsers and have poor versatility.
[0003] PTO MSS project users need to download files through the terminal each time to operate documents, and then use various tools to open and view them. In order to provide a better user experience, avoid this tedious operation, and strengthen the management and control of user permissions, this demand came into being. Summary of the invention
[0004] The purpose of the present invention is to provide a method for online previewing and downloading documents based on a microservice architecture.
[0005] The technical solution adopted by the present invention is:
[0006] A method for online previewing and downloading of documents based on a microservice architecture comprises the following steps:
[0007] Step 1: Upload the attachment through the VUE encapsulated component (OpenFileUpload.vue). When uploading, create a FormData object (containing file-related information)
[0008] Step 2: Call the backend API interface to process the file through the axios.post(url, data, config) method;
[0009] Step 3: Use the onUploadProgress method of axios to control the display of the attachment upload progress percentage;
[0010] Step 4: After uploading the file, the corresponding callback function is used to display the attachment information on the front end and load it to the local GFS storage server;
[0011] Step 5: When clicking the front-end attachment link address, execute window.open(URL) to obtain the API parameters provided for online preview or attachment download;
[0012] During online preview, the OnlinePreviewController.onlinePreview method receives the click request from the front end, determines the file type based on the passed parameter fullfilename, and calls the corresponding implementation class for preview processing;
[0013] When downloading an attachment, the filePreviewHandle method calls the backend FileController.downloadFile method through the URL to download the attachment based on the passed fileid value;
[0014] Step 6: After the attachment is downloaded, convert the file into PDF through the OPENOFFICE plug-in, and then display the PDF file on the front-end PC web page through the PDFJS plug-in.
[0015] For example, use public void openOfficeToPDF(String inputFilePath, StringoutputFilePath) to convert documents. inputFilePath: the file stream to be converted, and outputFilePath is converted into the PDF output stream. OfficeDocumentConverter converter = converterUtils.getDocumentConverter(); Create an OpenOffice document converter to convert files converterFile(inputFile, outputFilePath, converter).
[0016] Furthermore, in step 1, OpenFileUpload.vue is used to upload the file in pieces. Whether to upload in pieces can be realized through configuration). The implementation principle is as follows:
[0017] Furthermore, the specific steps of uploading in pieces in step 1 are as follows:
[0018] Step 1-1, split and read the file in the front end according to the configured file size,
[0019] Step 1-2, upload the read content in a loop and upload the attachment asynchronously.
[0020] Steps 1-3: After each file is successfully uploaded, a check is performed to determine whether all split files have been uploaded.
[0021] Steps 1-4: After uploading, call the backend API to merge the files.
[0022] Furthermore, the API parameters of window.open(URL) in step 5 include: securityCode is the signature parameter, fullfilename is the file name, and fileid is the file ID.
[0023] Furthermore, in step 5, the authority of the current user is determined by the signature parameter securityCode, and the corresponding online preview function or attachment download function is provided based on the user authority. According to different authorities, the user authority can be divided into situations such as no online preview and no attachment download, only online preview but no attachment download, no online preview but attachment download, and both online preview and attachment download.
[0024] Furthermore, in step 5, when fullfilename=onlineview.docx, the OfficeFilePreviewImpl.java implementation class is called for processing.
[0025] The present invention adopts the above technical solution, uploads large files through VUE encapsulation, and realizes asynchronous file stream information upload to the attachment class of the attachment upload function. The GFS distributed file system is saved through the file stream information, and when clicking to view, the GFS file stream information of the server is called to view, and the file stream is processed through the file browsing microservice, and the file online preview conversion API is forwarded through OpenOffice, providing users with online viewing of files in various formats.
[0026] The present invention performs document parsing through the back-end online preview capability and basically supports online preview of mainstream office documents through the rich text front-end preview function. The deployment and upgrade are simpler, faster and safer, and support the preview mode call of different system files. It supports security control verification of document viewing and downloading, providing a strong guarantee for the security management of enterprise documents. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments;
[0028] Figure 1 This is a schematic diagram of the architecture of a method for online previewing and downloading documents based on a microservice architecture of the present invention;
[0029] Figure 2 The present invention is a flowchart of a method for online previewing and downloading documents based on a microservice architecture. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0031] like Figure 1 As shown in FIG. 2 , the present invention discloses a method for online previewing and downloading of documents based on a microservice architecture, which comprises the following steps:
[0032] Step 1: Upload the attachment through the VUE encapsulated component (OpenFileUpload.vue). When uploading, create a FormData object (containing file-related information)
[0033] Step 2: Call the backend API interface to process the file through the axios.post(url, data, config) method;
[0034] Step 3: Use the onUploadProgress method of axios to control the display of the attachment upload progress percentage;
[0035] Step 4: After uploading the file, the corresponding callback function is used to display the attachment information on the front end and load it to the local GFS storage server;
[0036] Step 5: When clicking the front-end attachment link address, execute window.open(URL) to obtain the API parameters provided for online preview or attachment download;
[0037] During online preview, the OnlinePreviewController.onlinePreview method receives the click request from the front end, determines the file type (PDF, EXCEL, DOCX, etc.) based on the passed parameter fullfilename, and calls the corresponding implementation class for preview processing;
[0038] When downloading an attachment, the filePreviewHandle method calls the backend FileController.downloadFile method through the URL to download the attachment based on the passed fileid value;
[0039] Step 6: After the attachment is downloaded, convert the file into PDF through the OPENOFFICE plug-in, and then display the PDF file on the front-end PC web page through the PDFJS plug-in.
[0040] For example, use public void openOfficeToPDF(String inputFilePath, StringoutputFilePath) to convert documents. inputFilePath: the file stream to be converted, and outputFilePath is converted into the PDF output stream. OfficeDocumentConverter converter = converterUtils.getDocumentConverter(); Create an OpenOffice document converter to convert files converterFile(inputFile, outputFilePath, converter).
[0041] Furthermore, in step 1, OpenFileUpload.vue is used to upload the file in pieces. Whether to upload in pieces can be realized through configuration). The implementation principle is as follows:
[0042] Furthermore, the specific steps of uploading in pieces in step 1 are as follows:
[0043] Step 1-1, split and read the file in the front end according to the configured file size,
[0044] Step 1-2, upload the read content in a loop and upload the attachment asynchronously.
[0045] Steps 1-3: After each file is successfully uploaded, a check is performed to determine whether all split files have been uploaded.
[0046] Steps 1-4: After uploading, call the backend API to merge the files.
[0047] Specifically, the backend FileController class in the steps mainly provides the following APIs:
[0048] upload(@RequestParam("file") MultipartFile file, HttpServletRequestrequest) / / Upload file
[0049] uploadChunk(@RequestParam("file") MultipartFile file,HttpServletRequest request) / / Upload fragmented files
[0050] uploadMergeFile(@RequestBody(required = false) String jsonstr,HttpServletRequest request,HttpServletResponse response) / / File merge
[0051] downloadFile(HttpServletRequest req, HttpServletResponse resp,finalJSONObject form) / / File download.
[0052] Furthermore, the API parameters of window.open(URL) in step 5 include: securityCode is the signature parameter, fullfilename is the file name, and fileid is the file ID.
[0053] Furthermore, in step 5, the authority of the current user is determined by the signature parameter securityCode, and the corresponding online preview function or attachment download function is provided based on the user authority. According to different authorities, the user authority can be divided into situations such as no online preview and no attachment download, only online preview but no attachment download, no online preview but attachment download, and both online preview and attachment download.
[0054] Furthermore, in step 5, when fullfilename=onlineview.docx, the OfficeFilePreviewImpl.java implementation class is called for processing.
[0055] The present invention adopts the above technical solution, uploads large files through VUE encapsulation, and realizes asynchronous file stream information upload to the attachment class of the attachment upload function. The GFS distributed file system is saved through the file stream information, and when clicking to view, the GFS file stream information of the server is called to view, and the file stream is processed through the file browsing microservice, and the file online preview conversion API is forwarded through OpenOffice, providing users with online viewing of files in various formats.
[0056] The present invention performs document parsing through the back-end online preview capability and basically supports online preview of mainstream office documents through the rich text front-end preview function. The deployment and upgrade are simpler, faster and safer, and support the preview mode call of different system files. It supports security control verification of document viewing and downloading, providing a strong guarantee for the security management of enterprise documents.
[0057] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians of the art without making creative work are within the scope of protection of the present application.
Claims
1. A method for online preview and downloading of documents based on microservice architecture. Features: It includes the following steps: Step 1, upload the attachment through the VUE encapsulated component OpenFileUpload.vue, and create a FormData object when uploading; Step 2: Call the backend API interface to process the file through the axios.post(url, data, config) method. The URL is the API interface provided by the backend, data is the FormData object, and config is the configuration information. Step 3: Use the onUploadProgress method of axios to control the display of the attachment upload progress percentage; Step 4: After uploading the file, the corresponding callback function is used to display the attachment information on the front end and load it to the local GFS storage server; Step 5: When clicking the front-end attachment link address, execute window.open(URL) to obtain the API parameters provided for online preview or attachment download; During online preview, the OnlinePreviewController.onlinePreview method receives the click request from the front end, determines the file type based on the passed parameter fullfilename, and calls the corresponding implementation class for preview processing; When downloading an attachment, the filePreviewHandle method calls the backend FileController.downloadFile method through the URL to download the attachment based on the passed fileid value; Step 6: After the attachment is downloaded, convert the file into PDF through the OPENOFFICE plug-in, and then display the PDF file on the front-end PC web page through the PDFJS plug-in.
2. According to the method for online preview and downloading of documents based on microservice architecture in claim 1, Features: Step 1: Upload the file in pieces through OpenFileUpload.vue.
3. According to the method for online preview and downloading of documents based on microservice architecture in claim 2, Features: The specific steps for multi-part uploading in step 1 are as follows: Step 1-1, split and read the file in the front end according to the configured file size, Step 1-2, upload the read content in a loop and upload the attachment asynchronously. Steps 1-3: After each file is successfully uploaded, a check is performed to determine whether all split files have been uploaded. Steps 1-4: After uploading, call the backend API to merge the files.
4. According to the method for online preview and downloading of documents based on microservice architecture in claim 1, Features: The API parameters of window.open(URL) in step 5 include: securityCode is the signature parameter, fullfilename is the file name, and fileid is the file ID.
5. According to the method for online preview and downloading of documents based on microservice architecture in claim 4, Features: In step 5, the authority of the current user is determined by the signature parameter securityCode, and the corresponding online preview function or attachment download function is provided based on the user authority.
6. According to the method for online preview and downloading of documents based on microservice architecture in claim 1, Features: In step 5, when fullfilename=onlineview.docx, the OfficeFilePreviewImpl.java implementation class is called for processing.
Citation Information
Patent Citations
A method for online previewing network disk files
CN109213968A
File uploading grouping management method and device of UI framework, equipment and medium
CN111984596A
Rich text rendering method and rendering equipment
CN113656006A
File preview method, apparatus, and storage medium
WO2021003750A1
