A file uploading method and uploading device

By obtaining the fingerprint information of the file to be uploaded and determining whether there is a target file with the same content on the server, the problem of storing multiple copies of the same file in traditional technology is solved, and resource saving and multi-user sharing functions are realized.

CN112559464BActive Publication Date: 2025-01-21LUBAN (BEIJING) ELECTRONIC COMMERCE TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202011529695.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-22
Publication Date
2025-01-21
Estimated Expiration
2040-12-22

AI Technical Summary

Technical Problem

In traditional web projects, the same file may be shared among multiple users, resulting in multiple copies of the same file being stored in the server, occupying server hard disk resources.

Method used

By obtaining the fingerprint information of the file to be uploaded, it is determined whether there is a target file with the same content on the server. If it exists, update the upload parameters of the target file based on the characteristic information of the file to be uploaded to avoid repeated saving.

Benefits of technology

It effectively avoids the situation of multiple copies of the same file being stored, saves server hard disk resources, and enables multiple users to share files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112559464B_ABST
    Figure CN112559464B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a file uploading method and an uploading device, which relates to the field of computer technology and can solve the problem of storing multiple copies of the same file in a server, occupying the server hard disk resources. The method comprises: obtaining fingerprint information of a file to be uploaded, the fingerprint information is generated according to the file content of the file to be uploaded; setting a distributed lock using the fingerprint information as a keyword; judging whether there is a target file with the same file content as the file to be uploaded on the server side according to the fingerprint information; if so, updating the upload parameters of the target file according to the characteristic information of the file to be uploaded; and releasing the distributed lock. The present invention is suitable for processing file upload work.
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 and an uploading device. Background Art

[0002] In traditional web projects, file upload and download scenarios are inevitable. Since the same file may be shared among multiple users, when uploading files, it is inevitable that the same file will be uploaded by different people, resulting in the same file being stored in multiple parts on the server, which will occupy the server's hard disk resources. Summary of the invention

[0003] In view of this, an embodiment of the present invention provides a file uploading method and an uploading device, which can solve the problem of storing multiple copies of the same file in a server and occupying the server hard disk resources.

[0004] In a first aspect, an embodiment of the present invention provides a file uploading method, the method comprising: obtaining fingerprint information of a file to be uploaded, the fingerprint information being generated according to the file content of the file to be uploaded; setting a distributed lock using the fingerprint information as a keyword; judging, according to the fingerprint information, whether there is a target file on the server side whose file content is the same as the file content of the file to be uploaded; if so, updating the upload parameters of the target file according to the characteristic information of the file to be uploaded; and releasing the distributed lock.

[0005] Optionally, the characteristic information of the file to be uploaded includes the file name, file size, file fingerprint information, and uploader information; the upload parameters of the target file include the characteristic information of each upload and the total number of uploads; updating the upload parameters of the target file according to the characteristic information of the file to be uploaded includes: creating an association between the characteristic information of the file to be uploaded and the storage address of the target file; and adding 1 to the total number of uploads corresponding to the target file.

[0006] Optionally, after adding 1 to the total number of uploads corresponding to the target file, the method further includes: reducing 1 from the total number of uploads corresponding to the target file according to a deletion instruction for the file to be uploaded.

[0007] Optionally, when it is determined that the server does not have a target file whose file content is the same as the file content of the file to be uploaded, before releasing the distributed lock, the method also includes: obtaining the total number n of shards of the file to be uploaded; receiving the 1st to nth shard data of the file to be uploaded; integrating the shard data to generate an integrated file; generating fingerprint information of the integrated file based on the file content of the integrated file; determining whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; and if so, saving the integrated file.

[0008] Optionally, after saving the integrated file, the method further includes: creating an association relationship between characteristic information of the file to be uploaded and the storage address of the integrated file, the characteristic information of the file to be uploaded including file name, file size, file fingerprint information, and uploader information; and setting the total number of uploads corresponding to the integrated file to 1.

[0009] In a second aspect, an embodiment of the present invention provides a file uploading device, which is applied to a server, and the device includes: an acquisition unit, which is used to acquire fingerprint information of a file to be uploaded, and the fingerprint information is generated according to the file content of the file to be uploaded; a setting unit, which is used to set a distributed lock with the fingerprint information as a keyword; a judgment unit, which is used to judge whether there is a target file with the same file content as the file to be uploaded on the server according to the fingerprint information; an updating unit, which is used to update the upload parameters of the target file according to the characteristic information of the file to be uploaded if so; and a releasing unit, which is used to release the distributed lock.

[0010] Optionally, the characteristic information of the file to be uploaded includes the file name, file size, file fingerprint information, and uploader information; the upload parameters of the target file include the characteristic information of each upload and the total number of uploads; the update unit includes: a creation subunit, used to create an association between the characteristic information of the file to be uploaded and the storage address of the target file; a counting subunit, used to add 1 to the total number of uploads corresponding to the target file.

[0011] Optionally, the sub-counting unit is further used to: reduce the total upload times corresponding to the target file by 1 according to a deletion instruction for the file to be uploaded.

[0012] Optionally, the device also includes an integration unit, which is used to: obtain the total number n of fragments of the file to be uploaded; receive the 1st to nth fragment data of the file to be uploaded; integrate each of the fragment data to generate an integrated file; generate fingerprint information of the integrated file based on the file content of the integrated file; determine whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; if so, save the integrated file.

[0013] Optionally, the device also includes: a creation unit, used to create an association between the characteristic information of the file to be uploaded and the storage address of the integrated file, the characteristic information of the file to be uploaded including the file name, file size, file fingerprint information, and uploader information; a counting unit, used to set the total number of uploads corresponding to the integrated file to 1.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a shell, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the file upload method described in any of the above-mentioned embodiments.

[0015] In a fourth aspect, an embodiment of the present invention further provides a storage medium for storing an application program, wherein the application program is used to execute the file upload method described in any of the aforementioned embodiments.

[0016] In a fifth aspect, an embodiment of the present invention further provides an application for executing the file uploading method described in any of the aforementioned embodiments.

[0017] The embodiment of the present invention provides a file uploading method and uploading device, which obtains fingerprint information of a file to be uploaded, and the fingerprint information is generated according to the file content of the file to be uploaded; a distributed lock is set with the fingerprint information as a keyword; according to the fingerprint information, it is judged whether there is a target file with the same file content as the file to be uploaded on the server; if so, the upload parameters of the target file are updated according to the characteristic information of the file to be uploaded; and the distributed lock is released. In this way, before storing the file to be uploaded, it can be judged whether the server already has a target file with the same content. In the case that the server already has a target file with the same content, the file to be uploaded is no longer repeatedly saved, and only the characteristic information of the file to be uploaded is recorded, which solves the problem of storing multiple copies of the same file in the server and occupying the server hard disk resources, and realizes file sharing by multiple users; in addition, before processing the file to be uploaded, a distributed lock is set according to the fingerprint information of the file to be uploaded, and after the processing of the file to be uploaded is completed, the distributed lock is released, so that the same file can be effectively prevented from being uploaded in high concurrency, and the situation of storing multiple copies of the same file is further avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1A flowchart of a file uploading method provided in Embodiment 1 of the present invention;

[0020] Figure 2 A partial flow chart of a file uploading method provided in the first embodiment of the present invention;

[0021] Figure 3 A flowchart of a specific file uploading method provided by an embodiment of the present invention;

[0022] Figure 4 A schematic diagram of the structure of a file uploading device provided in Embodiment 2 of the present invention;

[0023] Figure 5 The figure is a schematic structural diagram of an embodiment of an electronic device of the present invention. DETAILED DESCRIPTION

[0024] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0025] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] Embodiment 1

[0027] like Figure 1 As shown, an embodiment of the present invention provides a file uploading method, which is applied to a server, and the method includes:

[0028] S101, obtaining fingerprint information of a file to be uploaded, where the fingerprint information is generated according to the file content of the file to be uploaded;

[0029] In this step, the fingerprint information can be obtained by encrypting the file content according to an encryption algorithm. The encryption algorithm can be an MD5 encryption algorithm. In this case, the fingerprint information of the file to be uploaded can be called the MD5 value of the file to be uploaded.

[0030] The server obtains the fingerprint information of the file to be uploaded, which may include: after the server temporarily stores the file to be uploaded, calculating the fingerprint information of the file to be uploaded according to an encryption algorithm, and in a subsequent step, if it is determined that the server already has a target file with the same file content as the file to be uploaded, then deleting the cached file to be uploaded from the server; or, the fingerprint information of the file to be uploaded is calculated by the user, and the server obtains the fingerprint information calculated by the user. In this way, compared with the previous method, it can avoid occupying the server bandwidth when uploading the file to be uploaded.

[0031] S102, using the fingerprint information as a keyword to set a distributed lock;

[0032] In this step, the distributed lock includes a keyword (key), and the distributed lock is set with the fingerprint information as the key of the distributed lock. For example, the distributed lock is set with the MD5 value of the file to be uploaded as the key of the distributed lock. In this way, if multiple user terminals upload the same file at the same time, only one user terminal can obtain the distributed lock. Other users need to wait for the user who has obtained the lock to release the distributed lock when operating. When other users obtain the lock, the current file has been uploaded, which can effectively prevent the scenario of uploading the same file under high concurrency.

[0033] S103, judging whether there is a target file with the same file content as the file to be uploaded on the server side according to the fingerprint information;

[0034] In this step, the fingerprint information of the file to be uploaded can be compared with the fingerprint information of the file stored in the server. When the generation rule of the fingerprint information of the file to be uploaded is the same as the generation rule of the fingerprint information of the file on the server, the file whose fingerprint information is the same as the fingerprint information of the file to be uploaded is the target file.

[0035] S104: If yes, updating the upload parameters of the target file according to the characteristic information of the file to be uploaded;

[0036] In this step, when the target file exists, that is, the file to be uploaded already exists on the server, there is no need to repeatedly upload the file to be uploaded. It is only necessary to save the characteristic information of the file to be uploaded to the server. In this way, the storage space of the server can be greatly saved.

[0037] Specifically, the upload parameters of the target file may be updated according to the characteristic information of the file to be uploaded; the characteristic information of the file to be uploaded may include the file name, file size, file fingerprint information, and uploader information; the upload parameters of the target file may include characteristic information of each upload and the total number of uploads; at this time, Figure 2 As shown, updating the upload parameters of the target file according to the characteristic information of the file to be uploaded may include:

[0038] S1041, creating an association relationship between the characteristic information of the file to be uploaded and the storage address of the target file;

[0039] S1042: Add 1 to the total number of upload times corresponding to the target file.

[0040] In this embodiment, since the file names, file sizes, and uploaders of other files to be uploaded that have the same file content as the target file may be different from the corresponding information of the target file, creating an association between the characteristic information of the files to be uploaded and the storage address of the target file can facilitate uploaders of other files to be uploaded to query, obtain, or delete the target file based on the characteristic information of the files to be uploaded that they uploaded.

[0041] The target file is provided with a total upload count, through which the total upload count of files with the same content as the target file can be counted. In this way, when the user terminal requests to delete a file to be uploaded that it has uploaded, the server terminal only needs to reduce the total upload count corresponding to the target file by 1 according to the deletion instruction of the file to be uploaded, without physically deleting the target file.

[0042] Optionally, the server may be provided with a relational database. In this case, the association relationship created in the above steps and the total number of uploads corresponding to the target file may be stored in the relational database.

[0043] S105: Release the distributed lock.

[0044] In this step, after the server completes processing the file to be uploaded, it releases the distributed lock, and other users who upload the same file can continue to upload the file. This can effectively prevent the same file from being uploaded in high concurrency situations, and can also avoid congestion when uploading large files.

[0045] The file uploading method provided by the embodiment of the present invention obtains the fingerprint information of the file to be uploaded, and the fingerprint information is generated according to the file content of the file to be uploaded; the distributed lock is set with the fingerprint information as a keyword; according to the fingerprint information, it is judged whether there is a target file with the same file content as the file to be uploaded on the server; if so, the upload parameters of the target file are updated according to the characteristic information of the file to be uploaded; and the distributed lock is released. In this way, before storing the file to be uploaded, it can be judged whether the server already has a target file with the same content. In the case that the server already has a target file with the same content, the file to be uploaded is no longer repeatedly saved, and only the characteristic information of the file to be uploaded is recorded, which solves the problem of storing multiple copies of the same file in the server and occupying the server hard disk resources, and realizes file sharing by multiple users; in addition, before processing the file to be uploaded, a distributed lock is set according to the fingerprint information of the file to be uploaded, and after the processing of the file to be uploaded is completed, the distributed lock is released, so that the same file can be effectively prevented from being uploaded in high concurrency, and the situation of storing multiple copies of the same file is further avoided.

[0046] Optionally, in the above embodiment, when it is determined that there is no target file on the server whose file content is the same as the file content of the file to be uploaded, before releasing the distributed lock, the method also includes: obtaining the total number n of shards of the file to be uploaded; receiving the 1st to nth shard data of the file to be uploaded; integrating the shard data to generate an integrated file; generating fingerprint information of the integrated file based on the file content of the integrated file; determining whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; and if so, saving the integrated file.

[0047] In this embodiment, when the size of the file to be uploaded is large, the file to be uploaded is uploaded in pieces, which can solve the problem that the large file size affects the upload or download speed, and can alleviate the problem that the large file size occupies the server bandwidth and causes the server to process other requests slowly. For example, the size of each piece of data can be controlled to about 5 megabytes.

[0048] In addition, after the fragment data are integrated, the present embodiment also compares the fingerprint information of the integrated file with the fingerprint information of the file to be uploaded to prevent errors in the integration of the fragment data. When it is determined that the fingerprint information of the integrated file is different from the fingerprint information of the file to be uploaded, that is, an error occurs when the fragment data is integrated, the integrated file can be deleted and the user end is notified of an error in uploading the file to be uploaded.

[0049] Optionally, in the above embodiment, after saving the integrated file, the method may further include: creating an association relationship between characteristic information of the file to be uploaded and the storage address of the integrated file, the characteristic information of the file to be uploaded including file name, file size, file fingerprint information, and uploader information; setting the total number of uploads corresponding to the integrated file to 1.

[0050] In this embodiment, since the integrated file is integrated from the fragmented data of the file to be uploaded, the integrated file stored by the server is equivalent to storing the content of the file to be uploaded. At this time, it is only necessary to record the association between the characteristic information of the file to be uploaded and the storage address of the integrated file, so that the uploader of the file to be uploaded can view, call or delete the integrated file according to the characteristic information of the file to be uploaded. The characteristic information of the file to be uploaded can also include the number of fragments when uploading the file to be uploaded.

[0051] Since the server does not have other files with the same content as the integrated file, the integrated file is uploaded for the first time to the server, and therefore the total number of uploads corresponding to the integrated file is set to 1.

[0052] like Figure 3 As shown, optionally, the receiving of the 1st to nth fragment data of the file to be uploaded; integrating each of the fragment data to generate an integrated file; may include: when the first fragment data of the file to be uploaded is received, creating an integrated file and writing the first fragment data into the integrated file; according to the fragment identifier of the fragment data, writing the other received fragment data into the integrated file in sequence.

[0053] Embodiment 2

[0054] like Figure 4 As shown, an embodiment of the present invention provides a file uploading device, which is applied to a server, and the device includes: an acquisition unit 21, which is used to acquire fingerprint information of a file to be uploaded, and the fingerprint information is generated according to the file content of the file to be uploaded; a setting unit 22, which is used to set a distributed lock with the fingerprint information as a keyword; a judgment unit 23, which is used to judge whether there is a target file on the server side with the same file content as the file content of the file to be uploaded according to the fingerprint information; an updating unit 24, which is used to update the upload parameters of the target file according to the characteristic information of the file to be uploaded if so; and a releasing unit 25, which is used to release the distributed lock.

[0055] Optionally, the characteristic information of the file to be uploaded includes the file name, file size, file fingerprint information, and uploader information; the upload parameters of the target file include the characteristic information of each upload and the total number of uploads; the update unit includes: a creation subunit, used to create an association between the characteristic information of the file to be uploaded and the storage address of the target file; a counting subunit, used to add 1 to the total number of uploads corresponding to the target file.

[0056] Optionally, the sub-counting unit is further used to: reduce the total upload times corresponding to the target file by 1 according to a deletion instruction for the file to be uploaded.

[0057] Optionally, the device also includes an integration unit, which is used to: obtain the total number n of fragments of the file to be uploaded; receive the 1st to nth fragment data of the file to be uploaded; integrate each of the fragment data to generate an integrated file; generate fingerprint information of the integrated file based on the file content of the integrated file; determine whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; if so, save the integrated file.

[0058] Optionally, the device also includes: a creation unit, used to create an association between the characteristic information of the file to be uploaded and the storage address of the integrated file, the characteristic information of the file to be uploaded including the file name, file size, file fingerprint information, and uploader information; a counting unit, used to set the total number of uploads corresponding to the integrated file to 1.

[0059] The device of this embodiment can be used to perform Figures 1 to 3 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.

[0060] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0061] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0062] In particular, 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.

[0063] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0064] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof.

[0065] In the above embodiments, multiple steps or methods may be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it may be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0066] An embodiment of the present invention further provides an electronic device, wherein the electronic device comprises the device described in any of the above embodiments.

[0067] Figure 5 This is a schematic diagram of the structure of an embodiment of the electronic device of the present invention, which can implement the present invention Figure 1-3 The process of the embodiment shown is as follows: Figure 5As shown, the above-mentioned electronic device may include: a shell 31, a processor 32, a memory 33, a circuit board 34 and a power supply circuit 35, wherein the circuit board 34 is arranged inside the space enclosed by the shell 31, and the processor 32 and the memory 33 are arranged on the circuit board 34; the power supply circuit 35 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 33 is used to store executable program codes; the processor 32 runs the program corresponding to the executable program code by reading the executable program code stored in the memory 33, so as to execute the file upload method described in any of the above-mentioned embodiments.

[0068] For details on the specific execution process of the above steps by the processor 32 and the steps further executed by the processor 32 by running the executable program code, please refer to the present invention. Figure 1-3 The description of the illustrated embodiment will not be repeated here.

[0069] This electronic device exists in many forms, including but not limited to:

[0070] (1) Mobile communication devices: These devices are characterized by their mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.

[0071] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDA, MID and UMPC devices, such as iPad.

[0072] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video players (such as iPods), handheld game consoles, e-books, smart toys, and portable car navigation devices.

[0073] (4) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0074] (5) Other electronic devices with data interaction functions.

[0075] An embodiment of the present invention further provides a storage medium for storing an application program, wherein the application program is used to execute a file uploading method provided by an embodiment of the present invention.

[0076] The embodiment of the present invention also provides an application program for executing the file uploading method provided by the embodiment of the present invention.

[0077] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0078] For the convenience of description, the above device is described by dividing the functions into various units / modules. Of course, when implementing the present invention, the functions of each unit / module can be implemented in the same or multiple software and / or hardware.

[0079] It can be seen from the above description of the embodiments that those skilled in the art can clearly understand the present invention.

[0080] The invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments of the present invention or certain parts of the embodiments.

[0081] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A file uploading method, characterized in that: Applied to the server, the method includes: Obtaining fingerprint information of the file to be uploaded, the fingerprint information is generated according to the file content of the file to be uploaded; the encryption algorithm is the MD5 encryption algorithm; the fingerprint information of the file to be uploaded is called the MD5 value of the file to be uploaded; The distributed lock is set with the fingerprint information as the keyword; the distributed lock is set with the MD5 value of the file to be uploaded as the key of the distributed lock; if multiple users upload the same file at the same time, only one user obtains the distributed lock, and other users need to wait for the user who obtains the lock to release the distributed lock when operating. When other users obtain the lock, the current file has been uploaded, which effectively prevents the same file from being uploaded in high concurrency. According to the fingerprint information, it is determined whether there is a target file on the server side with the same file content as the file to be uploaded; Wherein, judging whether there is a target file with the same file content as the file to be uploaded on the server side according to the fingerprint information includes: Compare the fingerprint information of the file to be uploaded with the fingerprint information of the file stored in the server, and when the generation rule of the fingerprint information of the file to be uploaded is the same as the generation rule of the fingerprint information of the file on the server, the file whose fingerprint information is the same as the fingerprint information of the file to be uploaded is the target file; If yes, then updating the upload parameters of the target file according to the characteristic information of the file to be uploaded; Get the total number n of fragments of the file to be uploaded; Receive the first to nth fragment data of the file to be uploaded; Integrate the fragmented data to generate an integrated file; wherein, receiving the first to nth fragmented data of the file to be uploaded; and integrating the fragmented data to generate an integrated file, including: Upon receiving the first fragment data of the file to be uploaded, creating an integrated file and writing the first fragment data into the integrated file; and writing the other received fragment data into the integrated file in sequence according to the fragment identifiers of the fragment data; Generating fingerprint information of the integrated file according to the file content of the integrated file; Determine whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; If yes, saving the integrated file; Releasing the distributed lock; Before releasing the distributed lock, the method further includes: obtaining the total number n of shards of the file to be uploaded; receiving the 1st to nth shard data of the file to be uploaded; integrating the shard data to generate an integrated file; generating fingerprint information of the integrated file according to the file content of the integrated file; judging whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; if so, saving the integrated file; after integrating the shard data, comparing the fingerprint information of the integrated file with the fingerprint information of the file to be uploaded to prevent errors in integrating the shard data; when judging that the fingerprint information of the integrated file is different from the fingerprint information of the file to be uploaded, that is, an error occurs when integrating the shard data, the integrated file is deleted and the user end is notified that the upload error of the file to be uploaded occurs; Wherein, after temporarily storing the file to be uploaded, the server calculates the fingerprint information of the file to be uploaded according to the encryption algorithm, and in a subsequent step, if it is determined that the server already has a target file with the same file content as the file to be uploaded, the cached file to be uploaded is deleted from the server; or, the fingerprint information of the file to be uploaded is calculated by the user end, and the server obtains the fingerprint information calculated by the user end; The characteristic information of the file to be uploaded includes the file name, file size, file fingerprint information, and uploader information; the upload parameters of the target file include the characteristic information of each upload and the total number of uploads; The updating of the upload parameters of the target file according to the characteristic information of the file to be uploaded includes: Creating an association relationship between the characteristic information of the file to be uploaded and the storage address of the target file; The total number of uploads corresponding to the target file is increased by 1; wherein the server is provided with a relational database, and the created association relationship and the total number of uploads corresponding to the target file are stored in the relational database; Wherein, after adding 1 to the total number of upload times corresponding to the target file, the method further includes: According to the deletion instruction of the file to be uploaded, the total upload times corresponding to the target file is reduced by 1; After saving the integrated file, the method further includes: Creating an association relationship between characteristic information of the file to be uploaded and the storage address of the integrated file, wherein the characteristic information of the file to be uploaded includes file name, file size, file fingerprint information, and uploader information; The total number of uploads corresponding to the integrated file is set to 1.

2. A file uploading device, characterized in that: Applied to the server, the device comprises: An acquisition unit is used to acquire fingerprint information of a file to be uploaded, wherein the fingerprint information is generated according to the file content of the file to be uploaded; the encryption algorithm is an MD5 encryption algorithm; the fingerprint information of the file to be uploaded is called the MD5 value of the file to be uploaded; A setting unit is used to set a distributed lock using the fingerprint information as a keyword; wherein the distributed lock is set using the MD5 value of the file to be uploaded as the key of the distributed lock; if multiple users upload the same file at the same time, only one user obtains the distributed lock, and other users need to wait for the user who obtains the lock to release the distributed lock when operating. When other users obtain the lock, the current file has been uploaded, which effectively prevents the same file from being uploaded in high concurrency; A judging unit, configured to judge whether there is a target file having the same file content as the file to be uploaded on the server side according to the fingerprint information; Wherein, judging whether there is a target file with the same file content as the file to be uploaded on the server side according to the fingerprint information includes: Compare the fingerprint information of the file to be uploaded with the fingerprint information of the file stored in the server, and when the generation rule of the fingerprint information of the file to be uploaded is the same as the generation rule of the fingerprint information of the file on the server, the file whose fingerprint information is the same as the fingerprint information of the file to be uploaded is the target file; an updating unit, configured to update the upload parameters of the target file according to the characteristic information of the file to be uploaded; The releasing unit is used to obtain the total number n of fragments of the file to be uploaded; receive the first to nth fragment data of the file to be uploaded; integrate the fragment data to generate an integrated file; wherein receiving the first to nth fragment data of the file to be uploaded; integrating the fragment data to generate an integrated file includes: Upon receiving the first fragment data of the file to be uploaded, creating an integrated file and writing the first fragment data into the integrated file; and writing the other received fragment data into the integrated file in sequence according to the fragment identifiers of the fragment data; Generate fingerprint information of the integrated file according to the file content of the integrated file; determine whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; if so, save the integrated file; and release the distributed lock; Before releasing the distributed lock, the method further includes: obtaining the total number n of shards of the file to be uploaded; receiving the 1st to nth shard data of the file to be uploaded; integrating the shard data to generate an integrated file, and generating fingerprint information of the integrated file according to the file content of the integrated file; judging whether the fingerprint information of the integrated file is the same as the fingerprint information of the file to be uploaded; if so, saving the integrated file; after integrating the shard data, comparing the fingerprint information of the integrated file with the fingerprint information of the file to be uploaded to prevent errors in integrating the shard data; when judging that the fingerprint information of the integrated file is different from the fingerprint information of the file to be uploaded, that is, an error occurs when integrating the shard data, the integrated file is deleted and the user end is notified that the upload error of the file to be uploaded occurs; Wherein, after temporarily storing the file to be uploaded, the server calculates the fingerprint information of the file to be uploaded according to the encryption algorithm, and in a subsequent step, if it is determined that the server already has a target file with the same file content as the file to be uploaded, the cached file to be uploaded is deleted from the server; or, the fingerprint information of the file to be uploaded is calculated by the user end, and the server obtains the fingerprint information calculated by the user end; The characteristic information of the file to be uploaded includes the file name, file size, file fingerprint information, and uploader information; the upload parameters of the target file include the characteristic information of each upload and the total number of uploads; The updating unit comprises: A creation subunit is used to create an association relationship between the characteristic information of the file to be uploaded and the storage address of the target file; A counting subunit is used to add 1 to the total number of uploads corresponding to the target file; wherein the server is provided with a relational database, and the created association relationship and the total number of uploads corresponding to the target file are stored in the relational database; Wherein, the counting subunit is also used for: According to the deletion instruction of the file to be uploaded, the total upload times corresponding to the target file is reduced by 1; Wherein, the device further comprises: A creating unit, used to create an association relationship between the characteristic information of the file to be uploaded and the storage address of the integrated file, wherein the characteristic information of the file to be uploaded includes the file name, file size, file fingerprint information, and uploader information; The counting unit is used to set the total upload times corresponding to the integrated file to 1.

Citation Information

Patent Citations

  • File uploading method and device, electronic device and storage medium

    CN109151059A

  • File uploading method and file uploading device in distributed object storage system

    CN109361772A

  • File fragment uploading method and device based on cloud technology, equipment and storage medium

    CN111414334A

  • Information processing method, electronic equipment and storage medium

    CN111522834A