File uploading method and device of server side, computer equipment and storage medium
The method enhances file upload speed and security by employing WebAssembly to perform hash calculations using MD5 and SHA256, addressing inefficiencies and vulnerabilities in existing file upload technologies.
Patent Information
- Application Number
- CN202411406004.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2024-12-31
AI Technical Summary
Existing file upload methods to servers are time-consuming and resource-intensive, particularly for large files, and suffer from security vulnerabilities due to the use of insecure hash algorithms like MD5 and SHA256, which can be cracked, leading to inefficient and unsafe file transmission.
A method that utilizes WebAssembly (WASM) technology to perform hash calculations using the MD5 and SHA256 algorithms, combining file type-specific identification information to enhance security and speed, allowing for rapid or normal uploads based on hash value verification.
Improves the speed and security of file uploads by using underlying programming languages like C or Rust within WASM to perform hash calculations, making the process less susceptible to cracking and reducing the time required for large files, while ensuring secure file transmission.
Smart Images

Figure CN119232726A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to a method, device, computer equipment and storage medium for uploading files on a server. Background Art
[0002] At present, when uploading a file to a server, it is necessary to calculate the unique hash value of the file to verify whether the current file has been uploaded to the server. If the server queries that the unique hash value exists, it means that the corresponding file has been uploaded. If the current user wants to continue uploading the file, he can perform rapid upload without uploading. The implementation technology of rapid upload uses algorithms such as md5 or sha256 to calculate the unique hash value on the browser side. The hash value generated by the MD5 algorithm is usually a 32-bit hexadecimal value, but it can collide with the market at present, so it is not very safe; the hash value length of the sha256 algorithm is 256 bits, which is much higher than the 32 bits of MD5, which is safer than md5, but the calculation running time is longer than the calculation time of md5. In addition, the security of md5 and sha256 lies in file collision (malicious cracking of the hash algorithm and malicious upload will cause other users to fail to upload rapidly). The more secure the hash algorithm, the longer it takes to run the calculation.
[0003] In summary, file uploading itself is time-consuming. If the unique hash value of each file needs to be calculated before uploading, it will be more time-consuming, especially for large files, and occupy browser resources. And the unique hash value of the file must be calculated, otherwise the file cannot be uploaded in seconds. Therefore, how to safely and efficiently implement file upload on the server side has become a problem that needs to be solved urgently. Summary of the invention
[0004] The present invention is intended to provide a file uploading method, device, computer equipment and storage medium on a server side to solve the deficiencies in the prior art. The technical problem to be solved by the present invention is achieved through the following technical solutions.
[0005] In a first aspect, an embodiment of the present invention provides a method for uploading a file on a server, comprising: In response to a file upload instruction triggered by a user, query a target file to be uploaded; Parsing the summary information of the target file and calculating the unique hash value corresponding to the target file based on a preset rule; Determine the upload strategy of the target file based on the summary information and the hash unique value; The target file upload on the server is completed based on the upload strategy.
[0006] In a possible implementation, the method further includes: Pre-set identification information corresponding to different file types; Corresponding target identification information is determined based on the file type of the target file.
[0007] In a possible implementation, the method further includes: Read the file stream of the target file, and perform hash calculation on the file stream by calling the md5 algorithm through the webassembly technology to obtain a first hash value; In combination with the target identification information corresponding to the file type of the target file and the first hash value, the sha256 algorithm is called to calculate and obtain a unique hash value corresponding to the target file.
[0008] In a possible implementation, the method further includes: The unique hash value corresponding to the target file is packaged into a wasm binary file.
[0009] In a possible implementation, the method further includes: Sending the summary information and the unique hash value to the server, so that the server determines whether the target file has been uploaded based on the summary information and the unique hash value; If yes, then determining that the upload strategy of the target file is a rapid upload operation; If not, it is determined that the upload strategy of the target file is a normal upload operation.
[0010] In a possible implementation, the method further includes: If it is determined that the upload policy of the target file is a rapid upload operation, then the target file is marked as uploaded; If it is determined that the upload policy of the target file is a normal upload operation, the target file is uploaded to the server, and the wasm binary file is sent to the wasm program at the same time, so that the wasm program performs hash calculation on the wasm binary file to obtain a second hash value.
[0011] In a possible implementation, the method further includes: Verifying the second hash value based on the unique hash value; After the target file is uploaded to the server, the server stores the unique hash value to mark that the target file has been uploaded.
[0012] In a second aspect, an embodiment of the present invention provides a file uploading device at a server, comprising: A response module, used to query the target file to be uploaded in response to the file upload instruction triggered by the user; A parsing and calculation module, used to parse the summary information of the target file and calculate a unique hash value corresponding to the target file based on a preset rule; A judgment module, used for judging the upload strategy of the target file based on the summary information and the hash unique value; The upload module is used to complete the target file upload on the server side based on the upload strategy.
[0013] In a third aspect, an embodiment of the present invention provides a computer device, comprising: a processor and a memory, wherein the processor is used to execute a file upload program on a server side stored in the memory to implement the file upload method on the server side described in the first aspect.
[0014] In a fourth aspect, an embodiment of the present invention provides a storage medium, including: the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the file upload method on the server side described in the first aspect above.
[0015] The embodiments of the present invention include the following advantages: The server-side file upload solution provided by the embodiment of the present invention queries the target file to be uploaded by responding to the file upload instruction triggered by the user; parses the summary information of the target file and calculates the unique hash value corresponding to the target file based on preset rules; determines the upload strategy of the target file based on the summary information and the unique hash value; and completes the upload of the target file on the server side based on the upload strategy. Compared with the traditional file upload method, which takes a lot of time to calculate the unique hash value for large files and occupies browser resources, and has the problem of low security of file transmission due to the simple calculation method, this solution uses the underlying programming language to read the file, improves the speed of hash calculation on the user side; performs binary processing on the hash calculation result, which is difficult to decompile and crack, thereby improving the security of file transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flowchart of the steps of an embodiment of a method for uploading files on a server side of the present invention; Figure 2 It is a flowchart of a method for calculating a unique hash value according to an embodiment of the present invention; Figure 3 It is a structural schematic diagram of an embodiment of a file uploading device at a server end of the present invention; Figure 4 It is a structural schematic diagram of a computer device of the present invention. DETAILED DESCRIPTION
[0017] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0018] Embodiment 1: Figure 1 is a flowchart of a method for uploading a file on a server side according to an embodiment of the present invention. Figure 1 As shown, the method specifically includes: S11. In response to a file upload instruction triggered by a user, query a target file to be uploaded.
[0019] In the embodiment of the present invention, the user can click on the user end to select the target file to be uploaded to the server end, and generate a file upload instruction. The user can directly click on the target file to select the upload instruction, or drag the target file to the upload waiting area and click to upload. The system determines the target file to be uploaded in response to the file upload instruction.
[0020] S12. Parse the summary information of the target file and calculate the unique hash value corresponding to the target file based on a preset rule.
[0021] The system program parses summary information of the target file, including but not limited to the file name, file size, file type, etc.
[0022] Furthermore, a calculation rule for a unique hash value corresponding to a file is pre-designed, and a unique hash value corresponding to the target file is calculated according to the preset calculation rule. The preset calculation rule is, for example: reading the file stream of the target file, and performing hash calculation on the file stream by calling the md5 algorithm through the webassembly technology to obtain a first hash value; combining the target identification information corresponding to the file type of the target file and the first hash value, calling the sha256 algorithm to calculate the unique hash value corresponding to the target file.
[0023] S13: Determine the upload strategy of the target file based on the summary information and the hash unique value.
[0024] S14. Complete the target file upload on the server side based on the upload strategy.
[0025] The target file summary information obtained by parsing and the calculated unique hash value corresponding to the target file are sent to the server. The server determines whether the target file has been uploaded based on the summary information and the unique hash value. The upload strategy of the target file is determined based on the judgment result, such as rapid upload or normal upload.
[0026] For example: if it is determined that the target file has been uploaded, the server notifies the user end, and the user end program performs a rapid transfer operation, directly marks the file as uploaded, and notifies the server end that the target file has been uploaded successfully.
[0027] If it is determined that the target file has not been uploaded, the normal file upload operation is performed. During the upload process, the target file can also be judged whether it has been changed based on the hash unique value. After the upload is successful, the server stores the hash unique value to mark that the target file has been uploaded.
[0028] The server-side file upload method provided by the embodiment of the present invention queries the target file to be uploaded by responding to the file upload instruction triggered by the user; parses the summary information of the target file and calculates the hash unique value corresponding to the target file based on the preset rules; determines the upload strategy of the target file based on the summary information and the hash unique value; and completes the upload of the target file on the server side based on the upload strategy. Compared with the traditional file upload method, which takes a lot of time to calculate the hash unique value for large files and occupies browser resources, and has the problem of low security of file transmission due to the simple calculation method, this method uses the underlying programming language to read the file, improves the speed of hash calculation on the user side; performs binary processing on the hash calculation result, which is difficult to decompile and crack, thereby improving the security of file transmission.
[0029] Embodiment 2: Figure 2 It is a flowchart of a method for calculating a unique hash value according to an embodiment of the present invention. Figure 2 As shown, the method specifically includes: S21. Pre-set identification information corresponding to different file types.
[0030] In the embodiment of the present invention, identification information corresponding to different file types is preset, for example, pdf type is 00001, word type is 00002, png type is 00003, jpg type is 00004, and the like.
[0031] S22: Determine corresponding target identification information based on the file type of the target file.
[0032] In the embodiment of the present invention, the user can click on the user end to select the target file to be uploaded to the server end, and generate a file upload instruction. The user can directly click on the target file to select the upload instruction, or drag the target file to the upload waiting area and click to upload. The system determines the target file to be uploaded in response to the file upload instruction.
[0033] Furthermore, the system program parses summary information of the target file, including but not limited to the file name, file size, file type, etc.
[0034] Further, the target identification information corresponding to the file type of the target file is determined according to the identification information corresponding to the preset different file types. For example, if the target file is of pdf type, the target identification information is 00001.
[0035] S23, reading the file stream of the target file, and performing hash calculation on the file stream by calling the md5 algorithm through the webassembly technology to obtain a first hash value.
[0036] In the embodiment of the present invention, the unique hash value corresponding to the target file is calculated, and the webassembly technology is used to improve the calculation speed and packaging. The webassembly technology itself runs faster than the browser, and the generated program is a binary file, which is difficult to crack.
[0037] Use the underlying programming language (for example, the underlying C language or Rust) to read the file stream of the target file, and then pass the file stream to the WebAssembly program. The WebAssembly program uses Rust or C language to call the md5 algorithm function to perform hash calculation on the file stream to obtain the first hash value, for example, 756002b7803103835656124fa263499.
[0038] S24. In combination with the target identification information corresponding to the file type of the target file and the first hash value, the sha256 algorithm is called to calculate and obtain a unique hash value corresponding to the target file.
[0039] Combined with the target identification information corresponding to the file type of the target file and the first hash value calculated above, the sha256 algorithm is called to perform a secondary hash character calculation to obtain a unique hash value corresponding to the target file.
[0040] For example: the first hash value is 75600f2678e310383566bf241263499, the target identification information is 00001, and the second hash character calculation results in the corresponding unique hash value of the target file: 12207d115318d62715813856b05a3ed821e472dd4308c76d575c7cd9922dc.
[0041] The first hash calculation of the file stream is to read and calculate the entire file, which is very time-consuming. The second character hash calculation is to perform a hash algorithm on characters such as the first hash value and the target identification information, which is very fast. The prior art directly reads the file through the js language and performs hash algorithm calculations. The essence is that js itself relies on the browser and belongs to the upper-level application language, and the speed is slower than the execution speed of the underlying C language. In addition, the difference between the prior art and the embodiment of the present invention is that after obtaining the file stream, the prior art can only perform hash calculations through js, and the user side can clearly see the algorithm content, while the embodiment of the present invention uses the webassembly program to perform hash calculations on the file stream, adds a secret key to the algorithm, and because it is a binary file, the algorithm program content cannot be viewed in the browser, ensuring the security of the file data.
[0042] S25. Pack the unique hash value corresponding to the target file into a wasm binary file.
[0043] In the embodiment of the present invention, the webassembly technology is used to package the unique hash value obtained by the above calculation into a wasm binary program file.
[0044] Furthermore, the summary information of the target file obtained by parsing and the unique hash value corresponding to the target file calculated are sent to the server, and the server determines whether the target file has been uploaded based on the summary information and the unique hash value. The upload strategy of the target file is determined based on the judgment result, such as rapid upload or normal upload.
[0045] For example, if the query finds that the server has stored the unique hash value corresponding to the target file, the upload policy of the target file is determined to be a rapid upload operation; otherwise, the upload policy of the target file is determined to be a normal upload operation. If it is determined that the target file has been uploaded, the server notifies the user end, and the user end program performs a rapid upload operation, directly marks the file as uploaded, and notifies the server end that the target file has been successfully uploaded.
[0046] If it is determined that the target file has not been uploaded, the normal upload operation of the file is performed. When uploading the file to the server, the packaged wasm file is uploaded at the same time. The webassembly technology transfers the file to the wasm program, and the wasm program performs hash calculation to ensure that the uploaded file has not been changed (security check).
[0047] The server-side file upload method provided in the embodiment of the present invention uses the underlying programming language to improve the speed of hash calculation on the user side, and performs binary processing on the hash algorithm technical process, which is difficult to decompile and crack. Anti-collision improvement: If the hash256 algorithm is used directly to calculate the hash value of the file, it is very time-consuming. If the md5 algorithm is used to calculate the hash value of the file, although the speed is relatively fast, the collision safety is low. Therefore, the embodiment of the present invention uses the md5 algorithm to calculate the hash value of the file, and then performs hash256 calculation based on the identification information of the file type, which can quickly calculate and further enhance the security of the hash value.
[0048] Figure 3 Schematic diagram of a file upload device embodiment of a server of the present invention. Figure 3 As shown, specifically including: The response module 301 is used to query the target file to be uploaded in response to the file upload instruction triggered by the user. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.
[0049] The parsing and calculating module 302 is used to parse the summary information of the target file and calculate the unique hash value corresponding to the target file based on a preset rule. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.
[0050] The judgment module 303 is used to judge the upload strategy of the target file based on the summary information and the hash unique value. For detailed description, please refer to the relevant description corresponding to the above method embodiment, which will not be repeated here.
[0051] The upload module 304 is used to complete the upload of the target file on the server side based on the upload strategy. For detailed description, please refer to the relevant description of the above method embodiment, which will not be repeated here.
[0052] The file uploading device at the server end provided in this embodiment may be as follows Figure 3 The file upload device on the server side shown in can execute the following Figure 1-2 All the steps of the file upload method on the server side are implemented Figure 1-2 For details, please refer to the technical effect of the file upload method on the server side. Figure 1-2 For the sake of brevity, the relevant description is not repeated here.
[0053] Figure 4 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention, Figure 4The computer device 400 shown includes: at least one processor 401, a memory 402, at least one network interface 404 and other user interfaces 403. The various components in the computer device 400 are coupled together via a bus system 405. It is understood that the bus system 405 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 405 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 405 is not shown in FIG. Figure 4 Various buses are labeled as bus system 405 .
[0054] The user interface 403 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0055] It can be understood that the memory 402 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The memory 402 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0056] In some implementations, the memory 402 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 4021 and application programs 4022 .
[0057] The operating system 4021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 4022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 4022.
[0058] In the embodiment of the present invention, by calling the program or instruction stored in the memory 402, specifically, the program or instruction stored in the application 4022, the processor 401 is used to execute the method steps provided by each method embodiment, for example, including: In response to a file upload instruction triggered by a user, a target file to be uploaded is queried; summary information of the target file is parsed and a unique hash value corresponding to the target file is calculated based on a preset rule; an upload strategy of the target file is determined based on the summary information and the unique hash value; and the target file upload on the server is completed based on the upload strategy.
[0059] In a possible implementation, identification information corresponding to different file types is preset; and the corresponding target identification information is determined based on the file type of the target file.
[0060] In one possible implementation, the file stream of the target file is read, and the md5 algorithm is called through the webassembly technology to perform hash calculation on the file stream to obtain a first hash value; in combination with the target identification information corresponding to the file type of the target file and the first hash value, the sha256 algorithm is called to calculate and obtain a unique hash value corresponding to the target file.
[0061] In a possible implementation, the unique hash value corresponding to the target file is packaged into a wasm binary file.
[0062] In one possible implementation, the summary information and the unique hash value are sent to a server, so that the server determines whether the target file has been uploaded based on the summary information and the unique hash value; if so, the upload policy of the target file is determined to be a rapid upload operation; if not, the upload policy of the target file is determined to be a normal upload operation.
[0063] In one possible implementation, if it is determined that the upload policy of the target file is a rapid upload operation, the target file is marked as uploaded; if it is determined that the upload policy of the target file is a normal upload operation, the target file is uploaded to the server, and the wasm binary file is sent to the wasm program at the same time, so that the wasm program performs hash calculation on the wasm binary file to obtain a second hash value.
[0064] In a possible implementation, the second hash value is verified based on the hash unique value; after the target file is uploaded to the server, the hash unique value is stored on the server to mark that the target file has been uploaded.
[0065] The method disclosed in the above embodiment of the present invention can be applied to the processor 401, or implemented by the processor 401. The processor 401 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 401 or the instruction in the form of software. The above processor 401 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiment of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 402, and the processor 401 reads the information in the memory 402 and completes the steps of the above method in combination with its hardware.
[0066] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0067] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0068] The computer device provided in this embodiment may be Figure 4 The computer device shown in , can execute Figure 1-2 All the steps of the file upload method on the server side are implemented Figure 1-2 For details, please refer to the technical effect of the file upload method on the server side. Figure 1-2 For the sake of brevity, the relevant description is not repeated here.
[0069] The embodiment of the present invention further provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0070] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned file uploading method on the server side executed on the computer device side can be implemented.
[0071] The processor is used to execute the file upload program of the server stored in the memory to implement the following steps of the file upload method of the server executed on the computer device side: In response to a file upload instruction triggered by a user, a target file to be uploaded is queried; summary information of the target file is parsed and a unique hash value corresponding to the target file is calculated based on a preset rule; an upload strategy of the target file is determined based on the summary information and the unique hash value; and the target file upload on the server is completed based on the upload strategy.
[0072] In a possible implementation, identification information corresponding to different file types is preset; and the corresponding target identification information is determined based on the file type of the target file.
[0073] In one possible implementation, the file stream of the target file is read, and the md5 algorithm is called through the webassembly technology to perform hash calculation on the file stream to obtain a first hash value; in combination with the target identification information corresponding to the file type of the target file and the first hash value, the sha256 algorithm is called to calculate and obtain a unique hash value corresponding to the target file.
[0074] In a possible implementation, the unique hash value corresponding to the target file is packaged into a wasm binary file.
[0075] In one possible implementation, the summary information and the unique hash value are sent to a server, so that the server determines whether the target file has been uploaded based on the summary information and the unique hash value; if so, the upload policy of the target file is determined to be a rapid upload operation; if not, the upload policy of the target file is determined to be a normal upload operation.
[0076] In one possible implementation, if it is determined that the upload policy of the target file is a rapid upload operation, the target file is marked as uploaded; if it is determined that the upload policy of the target file is a normal upload operation, the target file is uploaded to the server, and the wasm binary file is sent to the wasm program at the same time, so that the wasm program performs hash calculation on the wasm binary file to obtain a second hash value.
[0077] In a possible implementation, the second hash value is verified based on the hash unique value; after the target file is uploaded to the server, the hash unique value is stored on the server to mark that the target file has been uploaded.
[0078] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0079] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0080] It should be noted that the above detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the present application belongs.
[0081] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should also be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0082] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0083] In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0084] For ease of description, spatially relative terms, such as "above", "above", "on the upper surface of", "above", etc., may be used herein to describe the spatial positional relationship between a device or feature and other devices or features as shown in the figure. It should be understood that spatially relative terms are intended to include different orientations of the device in use or operation in addition to the orientation described in the figure. For example, if the device in the accompanying drawings is inverted, the device described as "above other devices or structures" or "above other devices or structures" will be positioned as "below other devices or structures" or "below other devices or structures". Thus, the exemplary term "above" may include both "above" and "below". The device may also be positioned in other different ways, such as rotated 90 degrees or in other orientations, and the spatially relative descriptions used herein are interpreted accordingly.
[0085] In the above detailed description, reference is made to the accompanying drawings, which form a part of this document. In the accompanying drawings, similar symbols typically identify similar components unless the context indicates otherwise. The illustrated embodiments described in the detailed description, drawings, and claims are not meant to be limiting. Other embodiments may be used, and other changes may be made, without departing from the spirit or scope of the subject matter presented herein.
[0086] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A file uploading method at a server, characterized in that: The method comprises: In response to a file upload instruction triggered by a user, query a target file to be uploaded; Parsing the summary information of the target file and calculating the unique hash value corresponding to the target file based on a preset rule; Determine the upload strategy of the target file based on the summary information and the hash unique value; The target file upload on the server is completed based on the upload strategy.
2. The method according to claim 1, characterized in that The summary information of the target file includes at least the file name, file size and file type; After parsing the summary information of the target file, the following steps are included: Pre-set identification information corresponding to different file types; Corresponding target identification information is determined based on the file type of the target file.
3. The method according to claim 2, characterized in that The calculating the unique hash value corresponding to the target file based on a preset rule includes: Read the file stream of the target file, and perform hash calculation on the file stream by calling the md5 algorithm through the webassembly technology to obtain a first hash value; In combination with the target identification information corresponding to the file type of the target file and the first hash value, the sha256 algorithm is called to calculate and obtain a unique hash value corresponding to the target file.
4. The method according to claim 3, characterized in that The method further comprises: The unique hash value corresponding to the target file is packaged into a wasm binary file.
5. The method according to claim 4, characterized in that The determining the upload strategy of the target file based on the summary information and the hash unique value includes: Sending the summary information and the unique hash value to the server, so that the server determines whether the target file has been uploaded based on the summary information and the unique hash value; If yes, then determining that the upload strategy of the target file is a rapid upload operation; If not, it is determined that the upload strategy of the target file is a normal upload operation.
6. The method according to claim 5, characterized in that The completing the target file upload on the server side based on the upload strategy includes: If it is determined that the upload policy of the target file is a rapid upload operation, then the target file is marked as uploaded; If it is determined that the upload policy of the target file is a normal upload operation, the target file is uploaded to the server, and the wasm binary file is sent to the wasm program at the same time, so that the wasm program performs hash calculation on the wasm binary file to obtain a second hash value.
7. The method according to claim 5, characterized in that The method further comprises: Verifying the second hash value based on the unique hash value; After the target file is uploaded to the server, the server stores the unique hash value to mark that the target file has been uploaded.
8. A file uploading device at a server, characterized in that: include: A response module, used to query the target file to be uploaded in response to the file upload instruction triggered by the user; A parsing and calculation module, used to parse the summary information of the target file and calculate a unique hash value corresponding to the target file based on a preset rule; A judgment module, used for judging the upload strategy of the target file based on the summary information and the hash unique value; The upload module is used to complete the target file upload on the server side based on the upload strategy.
9. A computer device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a file upload program on the server side stored in the memory to implement the file upload method on the server side according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the file uploading method of the server as described in any one of claims 1 to 7.
Citation Information
Cited By
File uploading method and file processing system
CN120499177A
File uploading method and file processing system
CN120499177B
