Disclosure of Invention
The invention provides a file transmission method, a file transmission device, file transmission equipment and a storage medium, which are used for reducing the expenditure of storage resources caused by repeated files and reducing the storage cost.
In a first aspect, an embodiment of the present invention provides a file transfer method, including:
acquiring a file uploading request of a first node, wherein the file uploading request comprises file information of a file to be uploaded;
searching a matched original file from a second node according to the file information of the file to be uploaded in the file uploading request;
and when an original file matched with the file to be uploaded exists in the second node, generating a link file pointing to the original file.
Optionally, the file transmission method further includes:
and when the original file matched with the file to be uploaded does not exist in the second node, storing the file to be uploaded to the second node.
Optionally, generating a link file pointing to the original file includes:
acquiring a relative path of the original file in the second node;
taking the relative path of the original file as the file content of the link file;
and generating the file name of the link file according to a preset strategy.
Optionally, after generating the link file pointing to the original file, the method further includes:
and recording the creation time of the link file.
Optionally, the file uploading request further includes a specified storage path of the file to be uploaded, and after generating the link file pointing to the original file, the method includes:
and storing the link file in a specified storage path.
Optionally, the specified storage path of the file to be uploaded is a relative path of the file to be uploaded in the first node.
Optionally, the first node is an external node outside the e-government affair system, and the second node is an internal node in the e-government affair system.
In a second aspect, an embodiment of the present invention further provides a file transmission apparatus, including:
the file uploading system comprises an uploading request acquisition module, a file uploading request processing module and a file uploading request processing module, wherein the uploading request acquisition module is used for acquiring a file uploading request of a first node, and the file uploading request comprises file information of a file to be uploaded;
the searching matching module is used for searching matched original files from the second node according to the file information of the files to be uploaded in the file uploading request;
and the link file generation module is used for generating a link file pointing to the original file when the original file matched with the file to be uploaded exists in the second node.
Optionally, the file transfer device further includes:
and the first storage module is used for storing the file to be uploaded to the second node when the original file matched with the file to be uploaded does not exist in the second node.
Optionally, the link file generating module includes:
the relative path acquisition sub-module is used for acquiring the relative path of the original file in the second node;
the file content determining submodule is used for taking the relative path of the original file as the file content of the link file;
and the file name generation submodule is used for generating the file name of the link file according to a preset strategy.
Optionally, the file transfer device further includes:
and the recording module is used for recording the creation time of the link file after the link file pointing to the original file is generated.
Optionally, the file uploading request further includes a specified storage path of the file to be uploaded, and the file transmission apparatus further includes:
and the second storage module stores the link file in a specified storage path after generating the link file pointing to the original file.
Optionally, the specified storage path of the file to be uploaded is a relative path of the file to be uploaded in the first node.
Optionally, the first node is an external node outside the e-government affair system, and the second node is an internal node in the e-government affair system.
In a third aspect, an embodiment of the present invention further provides a computer device, including:
one or more processors;
storage means for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the file transfer method as provided by the first aspect of the invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the file transfer method according to the first aspect of the present invention.
The file transmission method provided by the embodiment of the invention obtains the file uploading request of the first node, the file uploading request comprises the file information of the file to be uploaded, the matched original file is searched from the second node according to the file information of the file to be uploaded in the file uploading request, when the original file matched with the file to be uploaded exists in the second node, the link file pointing to the original file is generated, and the corresponding original file is found through the link file. Compared with the original file, the storage resource occupied by the link file is greatly reduced, and only the original file during the first transmission needs to be stored for one file, so that the storage resource overhead caused by repeated files is greatly reduced, and the storage cost is reduced.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a schematic flow diagram of a file transmission method according to an embodiment of the present invention, where this embodiment is applicable to a situation where the same file is repeatedly transmitted multiple times and the overhead of storage resources is relatively large, and the method may be executed by a file transmission apparatus according to an embodiment of the present invention, where the apparatus may be implemented by software and/or hardware, and is generally configured in a computer device, as shown in fig. 1, the method specifically includes the following steps:
s101, a file uploading request of a first node is obtained, wherein the file uploading request comprises file information of a file to be uploaded.
A node is a computer or other device connected to a network having an independent address and a function of transmitting or receiving data. The nodes may be workstations, clients, network users or personal computers, servers, printers and other network-connected devices. Each workstation, server, terminal device, network device, i.e. the device having its own unique network address, is a node. The whole network is composed of a plurality of nodes, and the plurality of nodes are connected by communication lines to form a certain geometrical relationship, namely a computer network topology.
When the first node has a file transmission requirement, the first node sends a file uploading request to the second node, and the second node receives the file uploading request. In this embodiment of the present invention, the first node may directly communicate with the second node, and the first node may also indirectly communicate with the second node through an intermediate communication device (for example, a router).
In this embodiment of the present invention, the file upload request includes file information of a file to be uploaded, where the file information may be a file name or an encoding representing a content of the file, and this embodiment of the present invention is not limited herein. In the embodiment of the present invention, if the file names or codes representing the contents of the files of the two files are the same, the two files are regarded as substantially the same file.
In the embodiment of the present invention, the file may be a text, a picture, a video, an audio, an executable file or a folder, and the like, and the type and format of the file are not limited in the embodiment of the present invention.
S102, searching for the matched original file from the second node according to the file information of the file to be uploaded in the file uploading request.
In the embodiment of the invention, after receiving the file uploading request, the second node analyzes the file uploading request, and analyzes the file information of the file to be uploaded from the file uploading request. And then, searching the matched original file from the second node according to the file information of the file to be uploaded in the file uploading request.
For example, in a Linux file system, a partition is mainly divided into two parts: a small part is used to save inode information (index) of the file, and the remaining large part is used to save block information. The default size of the inode is 128 bytes, which is used to record the authority (read, write and delete) of the file, the owner and the affiliation of the file, the size of the file, the state change time of the file, the last read time of the file, the last modification time of the file, and the block number of the file where the data is really stored, and each file needs to occupy one inode. The inode does not record file names, and the file names are recorded in the block of the directory where the files are located. Each file occupies an inode by itself, and the file contents are pointed to by the inode's records.
If the second node stores the original file matched with the file to be uploaded (namely the file to be uploaded and the original file are the same). And when the matched original file is searched from the second node according to the file information of the file to be uploaded in the file uploading request, searching the file name of the original file in the block where the directory is located. If the original file needs to be accessed, the inode of the original file needs to be found by means of the file name of the original file, and the block where the file content is located can be successfully found.
S103, when an original file matched with the file to be uploaded exists in the second node, a link file pointing to the original file is generated.
In the embodiment of the present invention, if the original file matched with the file to be uploaded is found in the second node, it is indicated that the file identical to the file to be uploaded already exists in the second node, at this time, only the link file pointing to the original file needs to be generated in the second node and stored. Compared with the original file, the storage space occupied by the link file is less than 100 bytes, the occupied storage resource is greatly reduced, and meanwhile, the corresponding original file can be found through the link file subsequently. When the same file as the original file is transmitted to the second node, a link file pointing to the original file is created again according to the method. Therefore, for one file, only the original file during the first transmission needs to be saved, the expenditure of storage resources caused by repeated files is greatly reduced, and the storage cost is reduced.
The file transmission method provided by the embodiment of the invention obtains the file uploading request of the first node, the file uploading request comprises the file information of the file to be uploaded, the matched original file is searched from the second node according to the file information of the file to be uploaded in the file uploading request, when the original file matched with the file to be uploaded exists in the second node, the link file pointing to the original file is generated, and the corresponding original file is found through the link file. Compared with the original file, the storage resource occupied by the link file is greatly reduced, and only the original file during the first transmission needs to be stored for one file, so that the storage resource overhead caused by repeated files is greatly reduced, and the storage cost is reduced.
Example two
Fig. 2 is a schematic flow chart of a file transmission method according to a second embodiment of the present invention, which is detailed based on the first embodiment, and the scheme of the second embodiment of the present invention is described in detail with reference to an e-government system, as shown in fig. 2, the method includes:
s201, a file uploading request of the first node is obtained, wherein the file uploading request comprises file information of a file to be uploaded.
With the enhancement of environmental awareness of people and the continuous upgrading of office mode requirements of various industries, the pace of modernization and informatization construction is accelerated, and paperless office work is gradually applied to an electronic government system by concepts. Electronic government refers to a brand new management mode for office work, management and public service provision for society by comprehensively applying modern information technology, network technology, office automation technology and the like in government activities.
When a user transacts electronic business with an e-government system, the e-government system often requires the user to upload identity information (e.g., a photograph or scanned piece of an identification card) to verify the user's identity. Since the identity information uploaded for many times is the same, if the identity information is saved each time, the storage overhead of the government affair system is inevitably huge.
In the embodiment of the invention, the nodes in the electronic government affairs system network are called internal nodes, and the nodes outside the electronic government affairs system network are called external nodes. The first node is an external node and the second node is an internal node.
When the external node has a file transmission requirement, the external node sends a file uploading request to the internal node, and the internal node receives the file uploading request. In an embodiment of the present invention, the external node may also indirectly communicate with the internal node through an intermediate communication device (e.g., a gateway, a router, etc.). In general, a gateway or a router does not intercept information sent out by an internal node, but identifies and screens information from an external node that wants to enter an internal network, and forwards the information to the internal node after the information is considered to be safe and effective.
In the embodiment of the present invention, the invention is described by taking the type of the transmitted document as a picture (an id card photograph or a scanned article). Generally, when a government affairs system requires a user to upload an identification card photo, the user is required to input the name and the identification number of the user at the same time, and the name and the identification number of the user can be recognized from the uploaded picture through Optical Character Recognition (OCR). The file uploading request comprises the name, the identification number and the like of the user. Of course, in other embodiments of the present invention, the file information may include the CRC32 code for the file.
In some embodiments of the present invention, the e-government system employs a distributed storage method, where the distributed storage is a data storage technology, and uses disk space on each machine in the enterprise through a network, and forms a virtual storage device with these distributed storage resources, and the data is stored in various nodes of the internal network in a distributed manner.
S202, searching for the matched original file from the second node according to the file information of the file to be uploaded in the file uploading request.
Since the identity information of each user is unique, the matched original file can be searched from the internal node through the identity information of the user.
S203, judging whether an original file matched with the file to be uploaded exists in the second node.
Specifically, if the return value of the search result is 0, it is determined that the original file matched with the file to be uploaded is not found in the internal node, that is, the same id card photo as the id card photo to be uploaded does not exist in the internal node, and at this time, step S204 is executed.
If the return value of the search result is 1, it is considered that the original file matched with the file to be uploaded is searched in the internal node, that is, the internal node already has the same id card photo as the id card photo to be uploaded, and at this time, steps S205-S208 are executed.
And S204, storing the file to be uploaded to the second node.
In the embodiment of the invention, if the identity card photo identical to the identity card photo to be uploaded does not exist in the internal node, the file to be uploaded is stored in the internal node.
In some embodiments of the present invention, the file upload request sent by the external node further includes a specified storage path of the file to be uploaded, and when the file to be uploaded is stored, the file to be uploaded is stored under the specified storage path of the internal node according to the specified storage path. Therefore, when the file is modified at any one of the internal node and the external node, the corresponding file in the other node can be correspondingly modified, the file synchronization of two file storage systems which are not communicated with each other in the network is realized, and the method can be applied to the internal and external network exchange scene of the e-government system.
In some embodiments of the present invention, the designated storage path of the file to be uploaded is a relative path of the file to be uploaded in the first node. The relative path refers to the path relationship with other files (or folders) caused by the path of the file. An absolute path is a path where a file actually exists on a hard disk, and is counted from the beginning of a disk character, if a file is located below "C: \ Program Files \ Jiangmin", then this path is its absolute path. A relative path may be understood as a portion of an absolute path and is a portion that does not include a system drive letter. And when the file to be uploaded is stored, storing the file to be uploaded under the appointed storage path of the internal node according to the relative path. In this way, even if a path change occurs in a certain node in the internal network, since the file is stored under the relative path, the file can still be found through the relative path.
S205, acquiring a relative path of the original file in the second node.
In the embodiment of the invention, if the identity card photo identical to the identity card photo to be uploaded already exists in the internal node, the relative path of the original file in the second node is obtained.
S206, taking the relative path of the original file as the file content of the link file.
In the embodiment of the present invention, after the relative path of the original file in the second node is obtained, the link file is generated, and the relative path of the original file in the second node is used as the file content of the link file. Illustratively, in the embodiment of the present invention, in order to be consistent with the format of the photo of the identification card to be uploaded, the link file is in a picture format (e.g.,. jpg), the link file can be edited by using a notepad, and the relative path of the original file in the second node is written into the link file. When the original file needs to be checked in the later period, the link file can be opened, the relative path in the link file is obtained, and the original file can be found and printed according to the relative path.
S207, generating the file name of the link file according to a preset strategy.
And generating a file name of the link file according to a preset strategy while generating the link file. Specifically, in the embodiment of the present invention, the file name of the link file includes node information of an external node (i.e., a node that uploads the file), the CRC32 code of the original file, the link file identification code, and the time when the link file is generated. When the original file needs to be checked in the later period, the link file is firstly positioned through the file name, the link file is opened, the relative path in the link file is obtained, and the original file can be found and printed according to the relative path.
Since the relative path of the original file in the internal node is stored in the link file, the original file can be found according to the relative path even if the absolute path of the original file in the internal node changes.
And S208, recording the creation time of the link file.
In the embodiment of the invention, the e-government system may record the creation time of the link file in order to record the occurrence time of the authentication.
S209, storing the link file in the designated storage path.
In the embodiment of the present invention, the file upload request further includes a specified storage path of the file to be uploaded, and when the link file is stored, the link file is stored in the specified storage path of the internal node according to the specified storage path. Therefore, when the link file is modified at any one of the internal node and the external node, the corresponding file in the other node can be correspondingly modified, the file synchronization of two file storage systems which are not communicated with each other in the network is realized, and the method can be applied to the internal and external network exchange scene of the e-government system.
In some embodiments of the present invention, the designated storage path of the file to be uploaded is a relative path of the file to be uploaded in the first node. And when the link file is stored, storing the file to be uploaded under the corresponding relative path in the internal node according to the relative path of the file to be uploaded in the first node. In this way, even if a path change occurs in a certain node in the internal network, since the file is stored under the relative path, the file can still be found through the relative path.
According to the file transmission method provided by the embodiment of the invention, when the original file matched with the file to be uploaded exists in the internal node, the link file pointing to the original file is generated, and the corresponding original file is found through the link file. Compared with the original file, the storage resource occupied by the link file is greatly reduced, and only the original file during the first transmission needs to be stored for one file, so that the storage resource overhead caused by repeated files is greatly reduced, and the storage cost is reduced. The file uploading request also comprises an appointed storage path of the file to be uploaded, and when the link file is stored, the link file is stored under the appointed storage path of the internal node according to the appointed storage path. Therefore, when the link file is modified at any one of the internal node and the external node, the corresponding file in the other node can be correspondingly modified, and the file synchronization of two file storage systems which are not communicated with each other in the network is realized. Further, the designated storage path of the file to be uploaded is a relative path of the file to be uploaded in the first node. In this way, even if a path change occurs in a certain node in the internal network, since the file is stored under the relative path, the file can still be found through the relative path.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a file transfer device according to a third embodiment of the present invention, and as shown in fig. 3, the file transfer device includes:
an uploadrequest obtaining module 301, configured to obtain a file upload request of a first node, where the file upload request includes file information of a file to be uploaded;
a searching andmatching module 302, configured to search a matched original file from a second node according to file information of a file to be uploaded in the file uploading request;
a linkfile generating module 303, configured to generate a link file pointing to the original file when the original file matching the file to be uploaded exists in the second node.
Optionally, the file transfer device further includes:
and the first storage module is used for storing the file to be uploaded to the second node when the original file matched with the file to be uploaded does not exist in the second node.
Optionally, the linkfile generating module 303 includes:
the relative path acquisition sub-module is used for acquiring the relative path of the original file in the second node;
the file content determining submodule is used for taking the relative path of the original file as the file content of the link file;
and the file name generation submodule is used for generating the file name of the link file according to a preset strategy.
Optionally, the file transfer device further includes:
and the recording module is used for recording the creation time of the link file after the link file pointing to the original file is generated.
Optionally, the file uploading request further includes a specified storage path of the file to be uploaded, and the file transmission apparatus further includes:
and the second storage module stores the link file in a specified storage path after generating the link file pointing to the original file.
Optionally, the specified storage path of the file to be uploaded is a relative path of the file to be uploaded in the first node.
The file transmission device can execute the file transmission method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the file transmission method.
Example four
A fourth embodiment of the present invention provides a computer device, and fig. 4 is a schematic structural diagram of the computer device provided in the fourth embodiment of the present invention, as shown in fig. 4, the computer device includes:
aprocessor 401, amemory 402, acommunication module 403, aninput device 404, and anoutput device 405; the number of theprocessors 401 in the mobile terminal may be one or more, and oneprocessor 401 is taken as an example in fig. 4; theprocessor 401, thememory 402, thecommunication module 403, theinput device 404 and theoutput device 405 in the mobile terminal may be connected by a bus or other means, and fig. 4 illustrates an example of a connection by a bus. Theprocessor 401,memory 402,communication module 403,input device 404, andoutput device 405 described above may be integrated on a computer device.
Thememory 402, which is a computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as the modules corresponding to the file transfer methods in the above embodiments. Theprocessor 401 executes various functional applications and data processing of the computer device by executing software programs, instructions and modules stored in thememory 402, that is, implements the file transfer method described above.
Thememory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the microcomputer, and the like. Further, thememory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, thememory 402 may further include memory located remotely from theprocessor 401, which may be connected to an electronic device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
And acommunication module 403, configured to establish a connection with an external device (e.g., an intelligent terminal), and implement data interaction with the external device. Theinput device 404 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function controls of the computer apparatus.
The computer device provided by this embodiment of the present invention is capable of executing the file transmission method provided by any of the above embodiments of the present invention, and has corresponding functions and advantageous effects.
EXAMPLE five
An embodiment of the present invention provides a storage medium containing computer-executable instructions, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the method for file transfer provided in any of the above embodiments of the present invention is implemented, where the method includes:
acquiring a file uploading request of a first node, wherein the file uploading request comprises file information of a file to be uploaded;
searching a matched original file from a second node according to the file information of the file to be uploaded in the file uploading request;
and when an original file matched with the file to be uploaded exists in the second node, generating a link file pointing to the original file.
It should be noted that, as for the apparatus, the device and the storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and in relevant places, reference may be made to the partial description of the method embodiments.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a robot, a personal computer, a server, or a network device) to execute the file transmission method according to any embodiment of the present invention.
It should be noted that, in the above apparatus, each included module is merely divided according to functional logic, but is not limited to the above division as long as the corresponding function can be achieved; in addition, the specific names of the functional modules are only for convenience of distinguishing from each other and are not used for limiting the protection scope of the present invention.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by suitable instruction execution devices. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.