A file uploading method, device, storage medium and equipment

By encapsulating multiple files in the request body of the file upload request and setting the form in the unified resource locator address, SpringCloud Feign solves the problem of low efficiency when uploading multiple files and achieves efficient file upload.

CN112543214BActive Publication Date: 2024-08-23BEIJING GRIDSUM TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910900494.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-23
Publication Date
2024-08-23
Estimated Expiration
2039-09-23

AI Technical Summary

Technical Problem

The existing SpringCloud Feign is inefficient and time-consuming when uploading multiple files, and the encoder does not support multiple file uploads, causing problems to easily occur when uploading multiple files with one request through Feign.

Method used

By encapsulating multiple files into one value and setting it in the request body of the file upload request, and setting the form corresponding to the file in the uniform resource locator address, a file upload request is generated to achieve uploading multiple files in one request.

Benefits of technology

It improves the speed and efficiency of multiple file uploads, avoids upload link problems caused by Feign calling serial execution, and achieves more efficient file uploads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112543214B
    Figure CN112543214B
Patent Text Reader

Abstract

The embodiment of the present invention provides a file upload method, device, storage medium and equipment, which relates to the field of information technology. The embodiment of the present invention obtains multiple files to be uploaded; generates a file upload request according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request; and sends the file upload request to a file server. The file and the form are set in different positions in the file upload request to realize the fast upload of multiple files through one request, thereby improving the efficiency of file upload.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a file uploading method, device, storage medium and equipment. Background Art

[0002] Feign is a declarative REST (Representational State Transfer) client that makes REST calls simpler and more convenient. It only takes three simple steps to completely proxy an HTTP (Hyper Text Transport Protocol) request. Therefore, the SpringCloud (an ordered collection of a series of frameworks) framework incorporates Feign into its components and improves it to make Feign calls simpler, finally achieving the effect of adding wings to a tiger.

[0003] However, since the encoder used by the existing SpringCloud Feign does not support encoding for multiple file uploads, and the Feign call is executed serially according to certain steps, if there is a problem in any link in the middle, the entire link will have problems, which can easily lead to problems when uploading multiple files to the file server through a single Feign call. Therefore, when uploading multiple files, the existing solution needs to upload multiple files, and only one file can be uploaded each time, which makes the file upload efficiency low and time-consuming when uploading multiple files. Summary of the invention

[0004] In view of the above problems, the present invention is proposed to provide a file uploading method and device that overcomes the above problems or at least partially solves the above problems.

[0005] According to one aspect of the present invention, a method for uploading a file is provided, comprising:

[0006] Get multiple files to be uploaded;

[0007] Generate a file upload request according to the multiple files; wherein the multiple files are located in a request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in a uniform resource locator address of the file upload request;

[0008] The file upload request is sent to a file server.

[0009] Optionally, the step of generating a file upload request according to the multiple files includes:

[0010] Parse the Feign related annotations declared in the source terminal for uploading multiple files, and obtain the target method handler corresponding to the Feign related annotations;

[0011] Constructing a request framework for the file upload request according to the target method processor;

[0012] The multiple files are placed in the request body of the request frame in the form of an encapsulated value, and the forms corresponding to the multiple files are placed in the uniform resource locator address of the request frame to obtain the file upload request.

[0013] Optionally, the step of placing the multiple files in the form of an encapsulated value in the request body of the request frame, placing the forms corresponding to the multiple files in the uniform resource locator address of the request frame, and obtaining the file upload request includes:

[0014] According to a first keyword corresponding to the multiple files, encapsulate the multiple files into a same value corresponding to the first keyword to obtain a first key-value pair corresponding to the multiple files;

[0015] For each information dimension included in the form, according to the second keyword corresponding to the information dimension, the information data corresponding to the information dimension is set in the value corresponding to the second keyword to obtain a second key-value pair corresponding to each information dimension;

[0016] The first key-value pair is placed in the request body of the request frame, and the second key-value pair is placed in the uniform resource locator address of the request frame to obtain the file upload request.

[0017] Optionally, the data type of the multiple files is a MultipartFile array type; the form includes supplementary description information and / or relevant business information of the multiple files; and the uniform resource locator address includes the uniform resource locator address of the file server.

[0018] Optionally, the step of encapsulating the multiple files into the same value corresponding to the first keyword according to the first keyword corresponding to the multiple files to obtain first key-value pairs corresponding to the multiple files includes:

[0019] Obtain file data of the MultipartFile array type corresponding to the multiple files;

[0020] According to the first keyword corresponding to the multiple files, the file data is encapsulated into the same value corresponding to the first keyword to obtain the first key-value pairs corresponding to the multiple files.

[0021] According to another aspect of the present invention, there is provided a file uploading device, comprising:

[0022] The upload file acquisition module is used to acquire multiple files to be uploaded;

[0023] A file upload request generation module, used to generate a file upload request according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request;

[0024] The file upload request sending module is used to send the file upload request to the file server.

[0025] Optionally, the file upload request generation module includes:

[0026] The method processor acquisition submodule is used to parse the Feign related annotations declared in the source terminal for uploading multiple files, and obtain the target method processor corresponding to the Feign related annotations;

[0027] A request framework construction submodule, used to construct a request framework for the file upload request according to the target method processor;

[0028] The file upload request generation submodule is used to place the multiple files in the request body of the request frame in the form of an encapsulated value, and place the forms corresponding to the multiple files in the uniform resource locator address of the request frame to obtain the file upload request.

[0029] Optionally, the file upload request generation submodule includes:

[0030] A first key-value pair obtaining unit, configured to encapsulate the plurality of files into a same value corresponding to the first keyword according to the first keyword corresponding to the plurality of files, so as to obtain first key-value pairs corresponding to the plurality of files;

[0031] A second key-value pair obtaining unit is configured to, for each information dimension included in the form, set the information data corresponding to the information dimension in the value corresponding to the second keyword according to the second keyword corresponding to the information dimension, so as to obtain a second key-value pair corresponding to each information dimension;

[0032] The file upload request generating unit is used to place the first key-value pair in the request body of the request frame, and place the second key-value pair in the uniform resource locator address of the request frame to obtain the file upload request.

[0033] Optionally, the data type of the multiple files is a MultipartFile array type; the form includes supplementary description information and / or relevant business information of the multiple files; and the uniform resource locator address includes the uniform resource locator address of the file server.

[0034] Optionally, the first key-value pair acquiring unit includes:

[0035] A file data acquisition subunit, used to acquire file data of a MultipartFile array type corresponding to the multiple files;

[0036] The first key-value pair acquisition subunit is used to encapsulate the file data into the same value corresponding to the first keyword according to the first keyword corresponding to the multiple files, so as to obtain the first key-value pairs corresponding to the multiple files.

[0037] According to another aspect of the present invention, a storage medium is provided, wherein the storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the above-mentioned file uploading method.

[0038] According to another aspect of the present invention, a device is provided, comprising at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; and the processor is used to call program instructions in the memory to execute the above-mentioned file uploading method.

[0039] In an embodiment of the present invention, multiple files to be uploaded are obtained; a file upload request is generated according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request; and the file upload request is sent to a file server. By encapsulating multiple files in the form of a value and setting it in the request body of the file upload request, and setting the forms corresponding to the multiple files in the uniform resource locator address of the file upload request, it is possible to upload multiple files to the file server through one request, thereby improving the upload rate of multiple file data.

[0040] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0042] Figure 1 A flowchart of a file uploading method according to an embodiment of the present invention is shown;

[0043] Figure 2 A flowchart showing another file uploading method according to an embodiment of the present invention is shown;

[0044] Figure 3 A structural block diagram of a file uploading device according to an embodiment of the present invention is shown;

[0045] Figure 4 A structural block diagram of another file uploading device according to an embodiment of the present invention is shown;

[0046] Figure 5 A structural block diagram of a device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0047] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0048] Embodiment 1

[0049] Reference Figure 1 , shows a flowchart of a file uploading method according to an embodiment of the present invention, which may specifically include the following steps:

[0050] Step 110, obtaining multiple files to be uploaded.

[0051] In the embodiment of the present invention, a user may send a request containing multiple files to a source terminal, and after receiving the multiple files, the source terminal may upload the multiple files to a corresponding file server.

[0052] In the embodiment of the present invention, the user can set the files to be uploaded in any available way, which is not limited by the embodiment of the present invention. For example, the user can access the source terminal for uploading files through a web page, and send the multiple files to be uploaded to the source client, etc. Moreover, in the embodiment of the present invention, the number of files that can be included in the multiple files to be uploaded can be customized according to requirements, which is not limited by the embodiment of the present invention. Moreover, the existence form of the multiple files can also be pre-set according to requirements, which is not limited by the embodiment of the present invention.

[0053] Step 120, generating a file upload request according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request.

[0054] As described in the background technology, the encoder used by Feign based on SpringCloud is SpringFormEncoder, which integrates an encoder of the Spring framework on the native form encoder (FormEncoder). When multiple files are uploaded (equivalent to multiple MultipartFiles, MultipartFile is a file format encapsulated by SpringMVC), the interface needs to use an array or collection to receive and then forward it to the Feign client. Feign will use the SpringFormEncoder encoder to encode and then send it to another interface. The encoding ultimately uses the SpringFormEncoder encoding method to encode the request, and the SpringFormEncoder encoding method does not support encoding for multiple file uploads, which leads to problems when Feign calls a request to upload multiple files to the file server or a request to upload a form + multiple files at the same time.

[0055] Then, in order to solve the above problem, both the form and the file can be uploaded in the request body, or the form and the file can be uploaded in the URL (Uniform Resource Locator) address. However, since the file is an input stream (InputStream), it can only be uploaded in the request body, and the form is not an input stream. If both the form and the file are uploaded in the request body, the encoder cannot encode it into an upload request. Therefore, in an embodiment of the present invention, the form can be placed in the URL address of the file upload request, and the file can be placed in the request body of the file upload request. Specifically, based on Feign remote call, a file upload request can be generated according to multiple files; wherein the multiple files can be located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request. Among them, the specific format of the encapsulated value can be pre-set according to the needs, and the embodiment of the present invention does not limit this, but it is necessary to ensure that all files to be uploaded are encapsulated as one value.

[0056] In actual applications, a request may generally include three parts: a request line, a request header, and a request body. Among them, the request line is divided into three parts: a request method, a request address, and a protocol and version, and ends with CRLF (rn). Therefore, in an embodiment of the present invention, the form corresponding to multiple files can be set in the URL address in the request line of the file upload request. Specifically, the form can be placed at the end of the URL address, or at the beginning of the URL address, or the form can be placed inside the URL address as required. Specifically, it can be pre-set as required, which is not limited by the embodiment of the present invention. The position and format of multiple files in the request body can also be pre-set as required, which is not limited by the embodiment of the present invention.

[0057] In addition, in an embodiment of the present invention, when uploading multiple files, forms corresponding to the multiple files can be set. In this case, the uploaded data is in the form of multiple files + forms. The forms corresponding to the multiple files can be located in the uniform resource locator address of the file upload request. If only multiple files are uploaded and the corresponding forms to be uploaded are not set, then there is no need to set the location of the form.

[0058] Step 130: Send the file upload request to the file server.

[0059] After the file upload request for multiple files is generated based on the Feign remote call, the file upload request can be further sent to the corresponding file server. Moreover, based on the operation process based on the Feign remote call, before the file upload request is sent to the file server, the file upload request can also pass through the log facade (Logger) and filter (Interceptors) of the functional component of the Feign remote call, and then be sent to the file server. Among them, the specific working content of the log facade and the filter can be pre-set according to the needs, and this embodiment of the present invention is not limited to this.

[0060] In an embodiment of the present invention, multiple files to be uploaded are obtained; a file upload request is generated according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request; and the file upload request is sent to a file server. The files and forms are set at different positions in the file upload request to achieve uploading of multiple files through one request, thereby improving the upload rate of multiple files.

[0061] Embodiment 2

[0062] Reference Figure 2 , shows a flowchart of another file uploading method according to an embodiment of the present invention, which may specifically include the following steps:

[0063] Step 210: Acquire multiple files to be uploaded.

[0064] Step 220, parse the Feign-related annotations declared in the source terminal used to upload multiple files, and obtain the target method handler corresponding to the Feign-related annotations.

[0065] like Figure 3The figure shows an existing Feign remote call flow chart based on SpringCloud. The dotted box shows the Feign core principle process, and the outside of the box shows the SpringCloud principle. Terminal A and Terminal B first register services with the Eureka cluster, and then use Eureka's service discovery to implement terminal A's remote call to terminal B through Feign. The main functional components of Feign include Contract (protocol rules), MethodHander (method processor), Encoder (encoder), Decoder (decoder), Interceptors (filter), and Logger (log facade). Each component has its own responsibilities and is interconnected. The main workflow is: the user (User) sends a request to terminal A; terminal A parses the Feign-related annotations declared in terminal A through the SpringMVCContract protocol specification; then finds the specified method processor, and obtains the Request entity object (Request Bean) through the corresponding method processor; then obtains the request request based on the Request entity object (Request Bean) by using the encoder (Encoder), and finally reaches terminal B through filters (Interceptors) and log facades (Logger); when terminal B completes the processing, the returned response (response) passes through the log facade and filter, and is finally parsed into a Response entity object (ResponseBean) by the decoder, and then finally converted into the target result through the method processor and SpringMVCContract protocol specifications.

[0066] In the embodiment of the present invention, the file upload is realized through the Feign remote call, and the above-mentioned terminal A can be set as the source terminal for realizing the file upload, and the terminal B can be set as the recipient of the uploaded file, that is, the file server. At this time, in order to improve the security of the file server, the relevant components of the Feign remote call can be set on the source terminal. Of course, the relevant components of the Feign remote call can also be set on the target server according to the needs, and this embodiment of the present invention is not limited. Among them, in the process of file upload, the Request entity object can be understood as multiple files to be uploaded and their corresponding forms.

[0067] Then, the user can trigger the upload of multiple files to be uploaded on the source terminal in any available way. After obtaining the multiple files to be uploaded, the source terminal can further parse the Feign-related annotations declared in the source terminal for uploading multiple files, and obtain the target method processor corresponding to the Feign-related annotations.

[0068] Step 230: construct a request framework for the file upload request according to the target method processor.

[0069] As mentioned above, in practical applications, if Figure 3 The Feign remote call process described above is prone to problems in uploading files. Therefore, in an embodiment of the present invention, when generating a file upload request, the file and the form need to be set separately, so the request framework of the file upload request can be first constructed according to the target method processor.

[0070] Specifically, other parameters required for constructing a file upload request, such as a request header, a request method, a request address, etc., can be obtained in addition to the multiple files and their corresponding forms. Then, a corresponding request framework can be generated according to the request format of the file upload request. At this time, the constructed request framework does not include the multiple files to be uploaded and the forms corresponding to the multiple files. The request address can include the address of the corresponding file server, etc.

[0071] The content included in the request frame, as well as the format and attributes of the request frame can be preset according to requirements, which is not limited in the embodiment of the present invention.

[0072] Step 240: Place the multiple files in the request body of the request frame in the form of an encapsulated value, place the forms corresponding to the multiple files in the uniform resource locator address of the request frame, and obtain the file upload request.

[0073] After constructing the request framework for the file upload request, multiple files can be further placed in the request body of the request framework in the form of an encapsulated value, and the forms corresponding to the multiple files can be placed in the uniform resource locator address of the request framework to obtain the file upload request.

[0074] In an embodiment of the present invention, the user may also customize the content to be uploaded according to needs, for example, only upload files, or only upload forms, or upload files and forms at the same time, and the forms may include forms corresponding to multiple files to be uploaded, and may also include forms unrelated to the multiple files to be uploaded. The specific settings can be pre-set according to needs, and this embodiment of the present invention is not limited to this.

[0075] Moreover, if the content to be uploaded includes multiple files, the multiple files to be uploaded can be placed in the request body of the request frame in the form of an encapsulated value. If the content to be uploaded includes a form, the corresponding form can be placed in the URL address of the request frame to obtain a file upload request.

[0076] Optionally, in the embodiment of the present invention, step 240 may further include:

[0077] Sub-step 241, according to the first keyword corresponding to the multiple files, encapsulate the multiple files into the same value corresponding to the first keyword to obtain first key-value pairs corresponding to the multiple files;

[0078] Sub-step 242, for each information dimension included in the form, according to the second keyword corresponding to the information dimension, the information data corresponding to the information dimension is set in the value corresponding to the second keyword, so as to obtain a second key-value pair corresponding to each information dimension;

[0079] Sub-step 243, placing the first key-value pair in the request body of the request frame, placing the second key-value pair in the uniform resource locator address of the request frame, and obtaining the file upload request.

[0080] As mentioned above, the encoder called by Feign remotely can only encode single file upload and character information. In the embodiment of the present invention, in order to meet the demand of uploading multiple files at the same time, it is necessary to be able to encode multiple files. Therefore, in the embodiment of the present invention, multiple files and forms to be uploaded can be set in the form of key-value pairs, and all files to be uploaded need to be encapsulated into the same value.

[0081] Therefore, in an embodiment of the present invention, all files to be uploaded can be set to correspond to a key value, so that all files to be uploaded can be encapsulated into the same value corresponding to the corresponding key value. Specifically, according to the same first keyword corresponding to all files to be uploaded, all files to be uploaded can be encapsulated into the same value corresponding to the first keyword, and the first key-value pair corresponding to the multiple files to be uploaded can be obtained. As for the form, since it is placed in the URL address, there is no need to encapsulate it. Therefore, for each information dimension contained in the form, the information data corresponding to the corresponding information dimension can be set in the value corresponding to the corresponding second keyword according to the second keyword corresponding to each information dimension, and the second key-value pair corresponding to each information dimension can be obtained; then the first key-value pairs corresponding to the multiple files to be uploaded can be placed in the request body of the request frame, and the second key-value pairs corresponding to the form to be uploaded can be placed in the uniform resource locator address of the request frame, so as to obtain a file upload request.

[0082] In addition, in an embodiment of the present invention, before placing the first key-value pair and the second key-value pair into the request frame, the first key-value pair and / or the second key-value pair may be encoded by a preset encoding method, and the encoded first key-value pair may be placed in the request body of the request frame, and the encoded second key-value pair may be placed in the uniform resource locator address of the request frame, thereby obtaining a file upload request. The encoding method may be preset as required, and is not limited by the embodiment of the present invention. For example, Feign may be used to remotely call the original encoder to encode the first key-value pair and the second key-value pair, and so on.

[0083] Optionally, in an embodiment of the present invention, the data type of the multiple files is a MultipartFile array type; the form includes supplementary description information and / or related business information of the multiple files; and the uniform resource locator address includes the uniform resource locator address of the file server.

[0084] As mentioned above, the embodiment of the present invention is to achieve simultaneous uploading of multiple files. In order to conveniently represent multiple files, multiple file data types can be set to MultipartFile array types. Among them, MultipartFile is a framework encapsulation type for files, and MultipartFile array refers to a data type composed of multiple MultipartFiles. Moreover, the form corresponding to the multiple files may include but is not limited to supplementary description information and / or related business information for each of the files to be uploaded, or the content contained in the form can also be customized, and so on. The supplementary description information and related business information are generally different from the file type. The supplementary description information and related business information generally exist in the form of a form. Generally speaking, the file to be uploaded is already in the request body, and two different and distinct types cannot be put in the request body. All supplementary description information and related business information can only be put in the URL address and uploaded together with the file.

[0085] Of course, in an embodiment of the present invention, if the supplementary information and / or related business information to be uploaded exists in a form other than a form, the supplementary information and / or related business information can also be placed in the URL address in other corresponding forms, and this embodiment of the present invention is not limited to this.

[0086] Moreover, in actual applications, in order to accurately send the file upload request to the file server, the file upload request should also include the URL address of the file server, that is, the URL address of the file upload request includes the URL address of the corresponding file server.

[0087] Optionally, in the embodiment of the present invention, the sub-step 241 may further include:

[0088] Step S1, obtaining file data of the MultipartFile array type corresponding to the multiple files;

[0089] Step S2: according to the first keyword corresponding to the multiple files, encapsulate the file data into the same value corresponding to the first keyword to obtain the first key-value pairs corresponding to the multiple files.

[0090] In an embodiment of the present invention, if a plurality of files are represented by a MultipartFile array, then when the plurality of files are converted into key-value pairs, the file data of the MultipartFile array type corresponding to the plurality of files can be directly obtained, and then according to the first keyword corresponding to the plurality of files, the corresponding file data can be set to the same value corresponding to the corresponding first keyword to obtain the first key-value pair corresponding to the plurality of files.

[0091] Step 250: Send the file upload request to the file server.

[0092] In an embodiment of the present invention, by parsing the Feign related annotations declared in the source terminal for uploading multiple files, and obtaining the target method processor corresponding to the Feign related annotations; constructing the request framework of the file upload request according to the target method processor; placing the multiple files in the request body of the request framework in the form of an encapsulated value, and placing the form corresponding to the multiple files in the uniform resource locator address of the request framework, the file upload request is obtained. Moreover, according to the first keyword corresponding to the multiple files, the multiple files can be encapsulated into the same value corresponding to the first keyword to obtain the first key-value pair corresponding to the multiple files; for each information dimension contained in the form, according to the second keyword corresponding to the information dimension, the information data corresponding to the information dimension is set in the value corresponding to the second keyword to obtain the second key-value pair corresponding to each information dimension; the first key-value pair is placed in the request body of the request framework, and the second key-value pair is placed in the uniform resource locator address of the request framework to obtain the file upload request. Furthermore, the file data of the MultipartFile array type corresponding to the multiple files is obtained; according to the first keyword corresponding to the multiple files, the file data is encapsulated into the same value corresponding to the first keyword to obtain the first key-value pair corresponding to the multiple files. The multiple files can be accurately set in the request body, and the form can be set in the URL address, thereby improving the effectiveness and efficiency of multiple file uploads.

[0093] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0094] Embodiment 3

[0095] Reference Figure 3 , shows a structural block diagram of a file upload device according to an embodiment of the present invention, the file upload device 300 may specifically include the following modules:

[0096] The upload file acquisition module 310 is used to acquire multiple files to be uploaded.

[0097] The file upload request generation module 320 is used to generate a file upload request based on the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request.

[0098] The file upload request sending module 330 is used to send the file upload request to the file server.

[0099] By acquiring multiple files to be uploaded; generating a file upload request according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request; and sending the file upload request to a file server. The files and forms are set in different positions in the file upload request to achieve multiple file uploads through one request, thereby improving the efficiency of multiple file uploads.

[0100] Reference Figure 4 , shows a structural block diagram of another file uploading device according to an embodiment of the present invention.

[0101] exist Figure 3 On the basis of, optionally, the file upload request generating module 320 may further include:

[0102] The method processor acquisition submodule 321 is used to parse the Feign related annotations declared in the source terminal for uploading multiple files, and obtain the target method processor corresponding to the Feign related annotations;

[0103] A request framework building submodule 322 is used to build a request framework for the file upload request according to the target method processor;

[0104] The file upload request generation submodule 323 is used to place the multiple files in the request body of the request frame in the form of an encapsulated value, and place the forms corresponding to the multiple files in the uniform resource locator address of the request frame to obtain the file upload request.

[0105] Optionally, in the embodiment of the present invention, the file upload request generating submodule 323 may further include:

[0106] A first key-value pair obtaining unit, configured to encapsulate the plurality of files into a same value corresponding to the first keyword according to the first keyword corresponding to the plurality of files, so as to obtain first key-value pairs corresponding to the plurality of files;

[0107] A second key-value pair obtaining unit is configured to, for each information dimension included in the form, set the information data corresponding to the information dimension in the value corresponding to the second keyword according to the second keyword corresponding to the information dimension, so as to obtain a second key-value pair corresponding to each information dimension;

[0108] The file upload request generating unit is used to place the first key-value pair in the request body of the request frame, and place the second key-value pair in the uniform resource locator address of the request frame to obtain the file upload request.

[0109] Optionally, in an embodiment of the present invention, the data type of the multiple files is a MultipartFile array type; the form includes supplementary description information and / or related business information of the multiple files; and the uniform resource locator address includes the uniform resource locator address of the file server.

[0110] Optionally, in the embodiment of the present invention, the first key-value pair obtaining unit may further include:

[0111] A file data acquisition subunit, used to acquire file data of a MultipartFile array type corresponding to the multiple files;

[0112] The first key-value pair acquisition subunit is used to encapsulate the file data into the same value corresponding to the first keyword according to the first keyword corresponding to the multiple files, so as to obtain the first key-value pairs corresponding to the multiple files.

[0113] In an embodiment of the present invention, by parsing the Feign related annotations declared in the source terminal for uploading multiple files, and obtaining the target method processor corresponding to the Feign related annotations; constructing the request framework of the file upload request according to the target method processor; placing the multiple files in the request body of the request framework in the form of an encapsulated value, and placing the form corresponding to the multiple files in the uniform resource locator address of the request framework, the file upload request is obtained. Moreover, according to the first keyword corresponding to the multiple files, the multiple files can be encapsulated into the same value corresponding to the first keyword to obtain the first key-value pair corresponding to the multiple files; for each information dimension contained in the form, according to the second keyword corresponding to the information dimension, the information data corresponding to the information dimension is set in the value corresponding to the second keyword to obtain the second key-value pair corresponding to each information dimension; the first key-value pair is placed in the request body of the request framework, and the second key-value pair is placed in the uniform resource locator address of the request framework to obtain the file upload request. Furthermore, the file data of the MultipartFile array type corresponding to the multiple files is obtained; according to the first keyword corresponding to the multiple files, the file data is encapsulated into the same value corresponding to the first keyword to obtain the first key-value pair corresponding to the multiple files. The multiple files can be accurately set in the request body, and the form can be set in the URL address, thereby improving the effectiveness of uploading multiple files and the efficiency of uploading multiple files.

[0114] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0115] The file uploading device includes a processor and a memory. The above-mentioned upload file acquisition module, file upload request generation module, file upload request sending module, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.

[0116] The processor includes a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and multiple files can be uploaded through one request by adjusting kernel parameters.

[0117] An embodiment of the present invention provides a storage medium on which a program is stored. When the program is executed by a processor, the file uploading method is implemented.

[0118] An embodiment of the present invention provides a processor, which is used to run a program, wherein the file uploading method is executed when the program is running.

[0119] Reference Figure 5 The embodiment of the present invention provides a device 40, which includes at least one processor 401, at least one memory 402 and a bus 403 connected to the processor 401; wherein the processor 401 and the memory 402 communicate with each other through the bus 403; the processor 401 is used to call the program instructions in the memory 402 to execute the above-mentioned file uploading method. The device in this article can be a server, a PC, a PAD, a mobile phone, etc.

[0120] The present application is described with reference to the flowcharts and / or block diagrams of the methods, device systems, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0121] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.

[0122] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.

[0123] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0124] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

[0125] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0126] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

[0127] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the description of the above specific languages ​​is for disclosing the best mode of the present invention.

[0128] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0129] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.

[0130] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0131] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.

[0132] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the file upload method and device device according to an embodiment of the present invention. The present invention may also be implemented as a device or device program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

Claims

1. A file uploading method, characterized in that: include: Get multiple files to be uploaded; Generate a file upload request according to the multiple files; wherein the multiple files are located in a request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in a uniform resource locator address of the file upload request; Sending the file upload request to a file server; Wherein, the step of generating a file upload request according to the multiple files includes: Parsing the Feign-related annotations declared in the source terminal for uploading the multiple files, and obtaining the target method handler corresponding to the Feign-related annotations; Constructing a request framework for the file upload request according to the target method processor; The multiple files are placed in the request body of the request frame in the form of an encapsulated value, and the forms corresponding to the multiple files are placed in the uniform resource locator address of the request frame to obtain the file upload request.

2. The method according to claim 1, characterized in that The step of placing the multiple files in the request body of the request frame in the form of an encapsulated value, placing the forms corresponding to the multiple files in the uniform resource locator address of the request frame, and obtaining the file upload request includes: According to a first keyword corresponding to the multiple files, encapsulate the multiple files into a same value corresponding to the first keyword to obtain a first key-value pair corresponding to the multiple files; For each information dimension included in the form, according to the second keyword corresponding to the information dimension, the information data corresponding to the information dimension is set in the value corresponding to the second keyword to obtain a second key-value pair corresponding to each information dimension; The first key-value pair is placed in the request body of the request frame, and the second key-value pair is placed in the uniform resource locator address of the request frame to obtain the file upload request.

3. The method according to any one of claims 1 to 2, characterized in that: The data type of the multiple files is a MultipartFile array type; the form includes supplementary description information and / or relevant business information of the multiple files; and the uniform resource locator address includes the uniform resource locator address of the file server.

4. The method according to claim 3, characterized in that The step of encapsulating the multiple files into the same value corresponding to the first keyword according to the first keyword corresponding to the multiple files to obtain the first key-value pairs corresponding to the multiple files includes: Obtain file data of the MultipartFile array type corresponding to the multiple files; According to the first keyword corresponding to the multiple files, the file data is encapsulated into the same value corresponding to the first keyword to obtain the first key-value pairs corresponding to the multiple files.

5. A file uploading device, characterized in that: include: The upload file acquisition module is used to acquire multiple files to be uploaded; A file upload request generation module, used to generate a file upload request according to the multiple files; wherein the multiple files are located in the request body of the file upload request in the form of an encapsulated value, and the forms corresponding to the multiple files are located in the uniform resource locator address of the file upload request; The file upload request sending module is used to send the file upload request to the file server. The file upload request generating module includes: A method processor acquisition submodule, used to parse the Feign related annotations declared in the source terminal used to upload the multiple files, and obtain the target method processor corresponding to the Feign related annotations; A request framework construction submodule, used to construct a request framework for the file upload request according to the target method processor; The file upload request generation submodule is used to place the multiple files in the request body of the request frame in the form of an encapsulated value, and place the forms corresponding to the multiple files in the uniform resource locator address of the request frame to obtain the file upload request.

6. The device according to claim 5, characterized in that The file upload request generation submodule includes: A first key-value pair obtaining unit, configured to encapsulate the plurality of files into a same value corresponding to the first keyword according to the first keyword corresponding to the plurality of files, so as to obtain first key-value pairs corresponding to the plurality of files; A second key-value pair obtaining unit is configured to, for each information dimension included in the form, set the information data corresponding to the information dimension in the value corresponding to the second keyword according to the second keyword corresponding to the information dimension, so as to obtain a second key-value pair corresponding to each information dimension; The file upload request generating unit is used to place the first key-value pair in the request body of the request frame, and place the second key-value pair in the uniform resource locator address of the request frame to obtain the file upload request.

7. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the file uploading method according to any one of claims 1 to 4.

8. A device comprising at least one processor, and at least one memory and bus connected to the processor; wherein: The processor and the memory communicate with each other via the bus; The processor is used to call the program instructions in the memory to execute the file uploading method according to any one of claims 1 to 4.