File distribution method, device, equipment, system, storage medium and program product
By setting a forced remote transmission flag in the file transfer request, and using terminal devices within the local area network to download file blocks, the concurrency pressure problem of the file distribution server is solved, and file transfer efficiency and network stability are improved.
Patent Information
- Application Number
- CN202211677026.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-26
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-12-26
AI Technical Summary
The file distribution server is under great concurrent pressure when facing large-scale concurrent file download tasks, which leads to network congestion and affects file transfer efficiency.
By setting a forced remote transmission flag in the file transfer request, if the remote transmission conditions are not met, the server obtains the terminal that has downloaded the target file within the local area network, sends the file transfer record and performs a validity check, and instructs the terminal whether to read the file block, thereby reducing the access pressure on the file distribution server.
By exchanging files within the local area network, the limited outbound bandwidth resources of the bank can be avoided, reducing the pressure on the file distribution server and improving network transmission efficiency.
Smart Images

Figure CN116248660B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of mobile Internet technology, and in particular to a file distribution method, device, equipment, system, storage medium and program product. BACKGROUND
[0002] Message interaction or file interaction is a common interaction mode in the field of mobile Internet.
[0003] In the field of banks and other financial institutions, file interaction type requests occupy a large amount of bandwidth resources. In the file interaction scene of batch version pushing, a large number of file interactions may cause the out-of-visit bandwidth resources in the bank to be tight, thereby affecting normal transactions. At the same time, terminal devices of multiple banks may send file download requests to a file distribution server. The file distribution server generates a file URL (Uniform Resource Locator, URL) and notifies the URL to the terminal devices in the bank by a predetermined manner. After the terminal devices obtain the URL, the terminal devices access the file distribution server to download target files.
[0004] When a large number of concurrent file download tasks occur, the file distribution server will bear a large concurrent pressure, and network congestion may occur, which may cause slow requests or access rejection, thereby affecting the file transmission efficiency. SUMMARY
[0005] Embodiments of the present application provide a file distribution method, device, equipment, system, storage medium and program product, which can solve the problem of network congestion caused by the file distribution server bearing a large concurrent pressure.
[0006] In a first aspect, embodiments of the present application provide a file distribution method applied to a server. Files in the server are stored in the form of file blocks, and a file graph is used to represent the start and end positions, file block storage capacity, file block verification information and file block identification of each file block. The method comprises the following steps:
[0007] Obtaining a file transmission request sent by a first terminal, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier;
[0008] In a case where the forced remote transmission identifier does not satisfy a remote transmission condition, obtaining a second terminal that has downloaded the target file in a same local area network according to the local area network identifier and the target file;
[0009] Sending a file transmission record of the second terminal to the first terminal, wherein the file transmission record comprises a terminal list, a file graph and a file transmission task identifier;
[0010] The verification request of the second terminal is checked for legitimacy based on the file transmission record, and a check result is sent to the second terminal, and the second terminal is indicated by the check result whether to read the file block of the target file and return to the first terminal.
[0011] In a second aspect, the embodiment of the present application further provides a file distribution method applied to a first terminal, and the method comprises:
[0012] A file transmission request is sent to a server, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier;
[0013] A file transmission record of a second terminal returned by the server is acquired, wherein the file transmission record comprises a terminal list, a file graph and a file transmission task identifier, and the second terminal is at least one terminal device which has downloaded a file block of the target file and is identical to the local area network identifier in the file transmission request;
[0014] A target file block is determined according to the file graph, target second terminals corresponding to each target file block in the terminal list are acquired, and the target second terminals are polled to acquire the target file block;
[0015] In a case where the target file block is completely transmitted, the target file block is spliced to obtain a target file according to the file graph.
[0016] In a third aspect, the embodiment of the present application further provides a file distribution device, and the device comprises a server, wherein files in the server are stored in the form of file blocks, and the start and end positions of each file block, file block storage capacity, file block verification information and file block identifiers are represented by a file graph, and the device comprises:
[0017] A request acquisition module is configured to acquire a file transmission request sent by a first terminal, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier;
[0018] A terminal acquisition module is configured to acquire, in a case where the forced remote transmission identifier does not satisfy a remote transmission condition, a second terminal which has downloaded a target file in a same local area network according to the local area network identifier and the target file;
[0019] A record sending module is configured to send a file transmission record of the second terminal to the first terminal, wherein the file transmission record comprises a terminal list, a file graph and a file transmission task identifier;
[0020] The verification module is configured to perform legality verification on the verification request of the second terminal based on the file transmission record, and send a verification result to the second terminal, wherein the verification result indicates whether the second terminal reads the file block of the target file and returns to the first terminal.
[0021] In a fourth aspect, the embodiments of the present application further provide a file distribution device applied to a first terminal, the device comprising:
[0022] The request sending module is configured to send a file transmission request to a server, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier.
[0023] The record obtaining module is configured to obtain a file transmission record of a second terminal returned by the server, wherein the file transmission record comprises a terminal list, a file map and a file transmission task identifier, and the second terminal is a terminal device having the same local area network identifier as the local area network identifier in the file transmission request and having downloaded at least one file block of the target file.
[0024] The file block request module is configured to determine a target file block according to the file map, obtain a target second terminal corresponding to each target file block in the terminal list, and poll the target second terminal to obtain the target file block.
[0025] The file splicing module is configured to splice the target file blocks to obtain a target file according to the file map when the transmission of the target file blocks is completed.
[0026] In a fifth aspect, the embodiments of the present application further provide an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable by the processor, wherein the processor implements the file distribution method of the first aspect or the file distribution method of the second aspect when executing the computer program.
[0027] In a sixth aspect, the embodiments of the present application further provide a file distribution system, comprising:
[0028] The server is configured to execute the file distribution method of the first aspect.
[0029] The first terminal is configured to execute the file distribution method of the second aspect.
[0030] The second terminal is configured to obtain a file download request sent by the first terminal, send a verification request to the server according to the file download request, and obtain a verification result returned by the server, wherein the verification request comprises a terminal identifier, a file transmission task identifier and a target file.
[0031] In the case that the verification result is a verification pass, the target file block is converted into a file stream, a file download response is generated according to the file stream, and the file download response is sent to the first terminal;
[0032] In the case that the verification result is a verification fail, a rejection response is sent to the file download request.
[0033] In a seventh aspect, the embodiments of the present application further provide a computer readable storage medium, which has a computer program stored thereon, and the computer program is executed by a processor to implement the file distribution method according to any one of the embodiments of the present application.
[0034] In an eighth aspect, the embodiments of the present application further provide a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the file distribution method according to any one of the embodiments of the present application.
[0035] In the embodiments of the present application, in the case that the forced remote transmission identifier in the file transmission request of the first terminal does not satisfy the remote transmission condition, the second terminal which has downloaded the target file in the same local area network is acquired according to the local area network identifier and the target file, the file transmission record of the second terminal is sent to the first terminal to inform the first terminal to download the file from the second terminal in the same local area network, the verification request of the second terminal is checked for legality based on the file transmission record, and the second terminal is returned to the first terminal by the check result to indicate whether the file block of the target file is read by the second terminal, so as to guarantee the security of file transmission. According to the present application, the file block is downloaded from the terminal device in the local area network, the limited outbound bandwidth resources of the bank are avoided from being occupied by a large number of file interactions, the normal transaction is not affected, in addition, the number of file interactions between the file distribution server and the first terminal is reduced, the access pressure borne by the file distribution server can be reduced, the problem of network congestion can be improved, and the service efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be considered as a limitation to the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.
[0037] Figure 1 A flow chart of a file distribution method provided by the embodiments of the present application;
[0038] Figure 2 A flow chart of another file distribution method provided by the embodiments of the present application;
[0039] Figure 3A flowchart of another file distribution method provided by an embodiment of the present invention;
[0040] Figure 4 A flowchart of another file distribution method provided by an embodiment of the present invention;
[0041] Figure 5 A flowchart of another file distribution method provided by an embodiment of the present invention;
[0042] Figure 6 A structural block diagram of a file distribution device provided by an embodiment of the present invention;
[0043] Figure 7 A structural block diagram of another file distribution device provided by an embodiment of the present invention;
[0044] Figure 8 A structural block diagram of an electronic device provided by an embodiment of the present invention;
[0045] Figure 9 This is a structural block diagram of a file distribution system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.
[0047] It should be noted that similar reference numerals and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined or explained in subsequent figures. Furthermore, in the description of the present invention, the terms "first," "second," etc. are used only to distinguish descriptions and should not be understood to indicate or imply relative importance. The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0048] Figure 1 This is a flowchart of a file distribution method provided in an embodiment of the present invention. This method can be applied to file distribution between bank branch devices and servers. This method can be performed by a file distribution device, which can be implemented using software and / or hardware and is typically deployed on a server. For example, the server can be a file distribution server or server cluster. Files on the server are stored in the form of file blocks, and a file map is used to represent the start and end locations of each file block, the file block storage capacity, file block verification information, and the file block identifier.
[0049] like Figure 1 As shown, the method includes:
[0050] S110, acquire a file transmission request sent by the first terminal.
[0051] The file transmission request is a file interaction request sent by a terminal device in the local area network to the server. For example, in a batch version pushing scenario, a terminal device in a bank outlet sends a file transmission request to a file distribution server. The file transmission request includes a local area network identifier, a terminal identifier, a target file, and a forced remote transmission identifier. The local area network identifier is used to identify the local area network to which the first terminal belongs. The terminal identifier is used to uniquely identify the first terminal. The target file is a file requested by the first terminal from the server. The forced remote transmission identifier is used to indicate that the file transmission request does not meet the remote transmission condition of directly obtaining the file block from the server when the forced remote transmission identifier is false. When the forced remote transmission identifier is true, the file transmission request meets the remote transmission condition of directly obtaining the file block from the server.
[0052] It should be noted that, on the server side, the file is stored in the form of file blocks. The server splits the file into n file blocks f1, f2, …, fn according to the configuration. The value of n is set according to actual needs, and the embodiments of the present application do not make specific limitations. Specifically, the server reads the complete original file as a file stream, truncates the file stream according to the specified file block storage capacity, and writes the truncated file stream to temporary files f1, f2, …, fn to obtain n file blocks. Splitting the file into file blocks can enhance the stability of file transmission, speed up file transmission, increase the fault tolerance rate of transmission, and increase the proportion of file transmission within the local area network.
[0053] The file block identifier, the start and end positions at the time of truncation, the length of the file block, and the MD5 value of the file block are recorded. The start and end positions of the file block, the file block storage capacity, and the file block verification information (such as the MD5 value) of each file block are stored in the form of key-value pairs, with the file block identifier as the key and the string composed of the corresponding file block start and end positions, length, and MD5 value as the value, to obtain the file map.
[0054] S120, in the case where the forced remote transmission identifier does not meet the remote transmission condition, acquiring a second terminal in the same local area network that has downloaded the target file according to the local area network identifier and the target file.
[0055] The second terminal is a terminal device in the same local area network as the first terminal and has downloaded part of the file blocks of the target file. A terminal list is formed based on the second terminal in the same local area network as the first terminal. Table 1 is a table of a terminal list.
[0056] Terminal identification File block Network address B1 f1, f2,... IP 1 B2 f1, f2,... IP 2 B3 f1, f2,... IP 3 …… …… …… Bm f1, f2,... IP m
[0057] Exemplarily, in the case that the forced remote transmission identifier does not satisfy the remote transmission condition, the file transmission completion record is queried according to the local area network identifier and the target file;
[0058] According to the query result, a terminal list of at least one second terminal belonging to the same local area network as the first terminal and having downloaded the target file is determined, wherein the terminal list contains the identifier information, network address and the identifier of the file block that has been downloaded of each second terminal.
[0059] Specifically, the server reads the forced remote transmission identifier in the file transmission request. When the forced remote transmission identifier is false, the file transmission completion record is queried according to the local area network identifier and the target file to determine whether there is a second terminal having downloaded the file block requested by the first terminal in the local area network to which the first terminal belongs (terminal list a). The content of the terminal list a can include the terminal identifier, terminal ip and the identifier of the successfully downloaded file block of each second terminal.
[0060] It should be noted that if the terminal list is empty, the server obtains the local target file block and sends the target file block to the first terminal; after each target file block passes the integrity check, the file transmission completion record is generated according to the local area network identifier, terminal identifier and target file block corresponding to the current file transmission task.
[0061] S130, the file transmission record of the second terminal is sent to the first terminal.
[0062] The file transmission record includes the terminal list, the file graph and the file transmission task identifier. It should be noted that the server sends the file graph to the first terminal when the first terminal requests the target file for the first time, and the first terminal triggers the integrity check according to the file graph after the file block is downloaded. The first terminal determines whether all the file blocks have been downloaded according to the file graph and determines the accuracy of the file block according to the md5 value in the graph.
[0063] Exemplarily, the file transmission record of the second terminal is generated according to the identifier information, network address, identifier of the file block that has been downloaded on the second terminal, file graph and file transmission task identifier of the second terminal, and the file transmission record is sent to the first terminal.
[0064] Specifically, the server transmits the second terminal obtained by the query file transmission completion record as a qualified terminal, and generates a terminal list according to the terminal identifier information, local area network IP information, and the list of file block identifiers that the qualified terminal has downloaded. The server transmits the terminal list, a file transmission task ID (for example, a 32-bit UUID), and the atlas data of the file block to the first terminal through a response message, and generates a file transmission record and saves the file transmission record to a database.
[0065] In an embodiment, the first terminal obtains the terminal list, the file transmission task ID (for example, a 32-bit UUID), and the atlas data of the file block according to the response message. The first terminal analyzes the locally missing file blocks (f1, f3, f4, …) according to the atlas data, and downloads the locally missing file blocks one by one. For the file block f1, the first terminal obtains the terminal list (B1, B2, …) of the downloaded file block f1 according to the terminal list. The first terminal polls the terminal list and sequentially requests to try to obtain the file block (assuming that the file block f1 is successfully obtained from B1, the polling is terminated, otherwise the first terminal requests the file f1 from B2, and after the polling of the list is completed and the file block f1 is not successfully obtained, the first terminal downloads the file block f1 from the server).
[0066] S140, performing legality verification on the verification request of the second terminal based on the file transmission record, sending the verification result to the second terminal, and indicating whether the second terminal reads the file block of the target file and returns to the first terminal through the verification result.
[0067] The legality verification is used to verify whether the file download request sent by the first terminal to the second terminal is legal. The file download request is a request sent by the first terminal to the second terminal to request to download a target file block. After receiving the file download request sent by the first terminal, the second terminal generates a verification request according to the terminal identifier, the file transmission task identifier UUID, and the file block identifier requested by the first terminal, and sends the verification request to the file distribution server.
[0068] For example, the verification request sent by the second terminal after receiving the file download request is obtained, and the legality of the file download request is determined through the verification request. The verification request includes a terminal identifier, a file transmission task identifier, and a target file. The terminal identifier, the file transmission task identifier, and the file block identifier sent by the second terminal are obtained by analyzing the verification request, and are matched with the file transmission record. If the match is consistent, it is determined that the verification request passes the legality verification.
[0069] Specifically, the server parses the verification request sent by the second terminal to obtain the terminal identifier, the file transmission task identifier UUID and the file block identifier requested by the first terminal, and matches the above information with the terminal identifier, the file transmission task identifier UUID and the corresponding file block identifier in the file transmission record respectively. If the terminal identifier, the UUID and the file block identifier are consistent, it is determined that the verification request passes the legality check, otherwise, it is determined that the verification request does not pass the legality check. The verification result is returned to the second terminal.
[0070] If the verification result is that the legality check fails, the second terminal rejects the file transmission request of the first terminal. If the verification result is that the legality check passes, the second terminal reads the local target file block, converts the target file block into a file stream, generates a file download response according to the file stream, and sends the file download response to the first terminal.
[0071] The embodiment of the present application provides a file distribution method. In the case that the forced remote transmission identifier in the file transmission request of the first terminal does not meet the remote transmission condition, the second terminal in the same local area network which has downloaded the target file is acquired according to the local area network identifier and the target file, the file transmission record of the second terminal is sent to the first terminal to inform the first terminal to download the file from the second terminal in the same local area network, and the verification request of the second terminal is checked for legality based on the file transmission record. The second terminal is indicated by the verification result whether to read the file block of the target file and returned to the first terminal, so that the legality of the request is checked before the file interaction in the local area network, the file leakage is avoided, and the security of the file transmission is ensured. According to the present application, the file block is downloaded from the terminal device in the local area network, the limited outbound bandwidth resources of the bank are avoided from being occupied by a large number of file interactions, the normal transaction is affected, in addition, the number of file interactions between the file distribution server and the first terminal is reduced, the access pressure borne by the file distribution server can be reduced, the problem of network congestion can be improved, and the service efficiency is improved.
[0072] Figure 2 Another flowchart of a file distribution method provided by the embodiment of the present application is shown in the figure. Figure 2 As shown in the figure, the method comprises the following steps.
[0073] S201, a file transmission request sent by a first terminal is acquired, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier.
[0074] S202, whether the remote transmission condition is met is judged according to the forced remote transmission identifier, if yes, S203 is executed, otherwise, S205 is executed.
[0075] S203, obtaining a target file block and sending the target file block to the first terminal.
[0076] In the case that the concurrent pressure of the file distribution of the server is not large, or in the case that it is known that no file needed is downloaded in the same LAN, or in other cases that the file must be directly transmitted by the server, the forced transmission identifier is set to true, so that the local file block is directly obtained by the server, and is returned to the first terminal in sequence through the response message. After the transmission of each file block is completed, a database record is inserted to record the association relationship between the LAN identifier, the terminal identifier and the target file block.
[0077] S204, generating a file transmission completion record according to the LAN identifier, the terminal identifier and the target file block corresponding to the current file transmission task after each target file block is verified.
[0078] S205, querying the file transmission completion record according to the LAN identifier and the target file.
[0079] S206, determining a terminal list of at least one second terminal which belongs to the same LAN as the first terminal and has downloaded the target file according to the query result, wherein the terminal list contains the identifier information, the network address and the identifier of the file block which has been downloaded of each second terminal.
[0080] S207, generating a file transmission record of the second terminal according to the identifier information, the network address, the identifier of the file block which has been downloaded on the second terminal, the file graph and the file transmission task identifier, and sending the file transmission record to the first terminal.
[0081] S208, parsing the verification request sent by the second terminal to obtain the terminal identifier, the file transmission task identifier and the file block identifier.
[0082] S209, matching the terminal identifier, the file transmission task identifier and the file block identifier obtained by parsing with the file transmission record.
[0083] S210, judging whether the matching result is consistent, if yes, executing S211, otherwise executing S213.
[0084] S211, determining that the verification request passes the legality verification.
[0085] S212, sending the verification result to the second terminal, instructing the second terminal to read the file block of the target file and return to the first terminal through the verification result, and continuing to execute S215.
[0086] S213, determining that the verification request does not pass the legality verification.
[0087] S214, sending the verification result to the second terminal, indicating the second terminal to reject the file download request of the first terminal through the verification result, indicating the first terminal to send the file download request to the next second terminal in the terminal list, and returning to perform S208.
[0088] S215, in the case that the integrity verification result sent by the first terminal is verified, generating a file transmission completion record according to the local area network identifier, the terminal identifier and the target file block corresponding to the current file transmission task.
[0089] The embodiment of the application provides a file distribution method, in the case that the forced remote transmission identifier is an indication that the server directly sends the target file block, the server directly reads the target file block from the local and returns to the first terminal, thereby improving the response speed of file transmission.
[0090] Figure 3 A flowchart of another file distribution method provided by the embodiment of the application is provided, which can be applied to the case of completing a large amount of file transmission in a local area network. The method can be executed by a file distribution device, which can be realized by software and / or hardware, and is usually configured in an electronic device. For example, the electronic device can be a terminal device in a bank branch that needs to download a target file. As shown in the figure, the method comprises: Figure 3
[0091] S310, sending a file transmission request to a server.
[0092] The file transmission request is a file interaction request sent by a terminal device in a local area network to a server. For example, in the scene of batch version pushing, a terminal device in a bank branch sends a file transmission request to a file distribution server. The file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier. The local area network identifier is used to identify the local area network to which the first terminal belongs. The terminal identifier is used to uniquely identify the first terminal. The target file is a file requested by the first terminal from the server. The forced remote transmission identifier is used to indicate whether the file transmission request meets the remote transmission condition. When the forced remote transmission identifier is false, the file transmission request does not meet the remote transmission condition of directly obtaining a file block from the server. When the forced remote transmission identifier is true, the file transmission request meets the remote transmission condition of directly obtaining a file block from the server.
[0093] S320, obtaining the file transmission record of the second terminal returned by the server.
[0094] The file transmission record includes a terminal list, a file map, and a file transmission task identifier, the second terminal is a terminal device that has downloaded at least one file block of the target file and has the same local area network identifier as the local area network identifier in the file transmission request.
[0095] The second terminal is a terminal device that has downloaded part of the file blocks of the target file and is in the same local area network as the first terminal. The terminal list is formed based on the second terminal in the same local area network as the first terminal.
[0096] It should be noted that the file is stored in the form of a file block on the server side. The server splits the file into n file blocks f1, f2,..., fn according to the configuration, and the value of n is set according to actual needs, and the embodiments of the present application do not make specific limitations. Specifically, the server reads the complete original file as a file stream, truncates the file stream according to the specified file block storage capacity, and writes the truncated file stream to temporary files f1, f2,..., fn to obtain n file blocks. Record the file block identifier, the start and end positions when truncating, the length of the file block, and the MD5 value of the file block. Take the file block identifier as the key key, and take the string composed of the start and end positions, the length of the corresponding file block, and the MD5 value of the file block as the value value, and store the start and end positions of each file block, the file block storage capacity, and the file block verification information (such as the MD5 value) in the form of key-value pairs to obtain the file map.
[0097] The file transmission task identifier can be a 32-bit UUID, which is used to uniquely identify the file transmission task.
[0098] Specifically, the server takes the second terminal obtained by querying the file transmission completion record as a qualified terminal, and forms a terminal list according to the terminal identifier information, the local area network IP information, and the list of file block identifiers that the terminal has downloaded. The terminal list, the file transmission task ID (such as a 32-bit UUID), and the file block map data are notified to the first terminal through a response message, and a file transmission record is generated and saved to the database.
[0099] S330, according to the file map, determine the target file block, obtain the target second terminal corresponding to each target file block in the terminal list, and poll the target second terminal to obtain the target file block.
[0100] Exemplarily, the first terminal determines target file blocks locally lacking according to a file map. Target second terminals having downloaded corresponding target file blocks are determined according to the terminal list queried according to the target file blocks. File download requests are respectively sent to the target second terminals corresponding to each target file block, the target second terminals send verification requests to a server according to the file download requests, and target file blocks are converted into file streams according to verification results, and file download responses are generated according to the file streams, wherein the verification requests include terminal identifiers, file transmission task identifiers and target file blocks. File download responses returned by the target second terminals are acquired, and file download states corresponding to the file download requests are acquired according to the file download responses. For each target file block, in a case where the file download state is download failure, a file download request is sent to a next target second terminal until the file download state is download success.
[0101] Specifically, the first terminal obtains a terminal list, a file transmission task ID (for example, a 32-bit UUID) and map data of file blocks according to a response message. The locally lacking file blocks (f1, f3, f4,...) are analyzed according to the map data, and the locally lacking file blocks are downloaded one by one. For the file block f1, a terminal list having downloaded the file block f1 is acquired according to the terminal list (B1, B2,...). The terminal list is polled, and file blocks are sequentially requested and attempted to be acquired (it is assumed that the file block f1 is successfully acquired from B1, and the polling is terminated, otherwise the file f1 is requested from B2, and the terminal list is polled and the file block f1 is not successfully acquired, and the file block f1 is downloaded from the server).
[0102] S340, in a case where the target file blocks are all transmitted, the target file blocks are spliced to obtain a target file according to the file map.
[0103] Exemplarily, file streams of target file blocks are obtained by analyzing the file download responses; the file streams are sequentially read into the target file blocks in a chain form according to start and end positions of the target file blocks in the file map; whether all target file blocks of the target file are downloaded is determined according to the file map; if yes, the target file blocks are spliced to obtain the target file according to the start and end positions.
[0104] After the file blocks are downloaded, the first terminal triggers integrity verification according to the file map. The first terminal determines whether all file blocks are downloaded locally according to the file map, and determines the accuracy of the file blocks according to md5 values in the map. If the file is accurate, the file streams are written into a newly created file to obtain the target file.
[0105] The embodiment of the present application provides a file distribution method, by sending a file transmission request to a server, obtaining a file transmission record of a second terminal returned by the server, downloading a file from the second terminal in the same local area network according to the file transmission record, transmitting the file in the form of a file block, which can enhance file transmission stability, accelerate file transmission speed, increase transmission fault tolerance, increase file transmission proportion in the local area network, reduce outbound bandwidth resource consumption, and splice file blocks according to a file map to obtain a target file after the file block is downloaded. The file block is downloaded from the terminal device in the local area network, which avoids occupying limited outbound bandwidth resources of the bank due to a large number of file interactions, affects normal transactions, in addition, the number of file interactions between the file distribution server and the first terminal is reduced, the access pressure borne by the file distribution server is reduced, the network congestion problem is improved, and the service efficiency is improved.
[0106] Figure 4 The flowchart of another file distribution method provided by the embodiment of the present application, the embodiment further introduces a file download state corresponding to a file download request according to a file download response on the basis of the above-mentioned embodiment. As shown in the figure, Figure 4 The method comprises the following steps.
[0107] S401, a file transmission request is sent to a server, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier.
[0108] S402, in the case that the forced remote transmission identifier is false, a file transmission record of a second terminal returned by the server is obtained.
[0109] The file transmission record comprises a terminal list, a file map and a file transmission task identifier, and the second terminal is at least one terminal device which has downloaded a file block of the target file and is the same as the local area network identifier in the file transmission request.
[0110] S403, a target file block is determined according to the file map, and a target second terminal corresponding to each target file block in the terminal list is obtained.
[0111] S404, a file download request is sent to each target second terminal corresponding to each target file block respectively, a verification request is sent to the server by the target second terminal according to the file download request, a target file block is converted into a file stream according to a verification result, and a file download response is generated according to the file stream.
[0112] The verification request comprises a terminal identifier, a file transmission task identifier and a target file block.
[0113] For example, for the file block f1, a terminal list (B1, B2, …) that has downloaded the file block f1 is obtained according to the terminal list. A file download request for the file block f1 is sent to B1 first. If the file block f1 is successfully obtained from B1, the polling is terminated. Otherwise, a file download request for the file block f1 is sent to B2, and the process is continued until the file block f1 is obtained. If the list is polled and the file block f1 is not successfully obtained, the file block f1 is downloaded from the server. After receiving the file download request for the file block f1, B1 sends a verification request to the server to determine the legality of the file download request, wherein the verification request includes the terminal identifier B1, the file transmission task identifier UUID, and the file block f1. The server parses the verification request sent by B1 to obtain the terminal identifier B1, the file transmission task identifier UUID, and the file block f1, and matches the terminal identifier B1, the file transmission task identifier UUID, and the file block f1 obtained by parsing with the file transmission record. If the match is consistent, it is determined that the verification request passes the legality check.
[0114] The second terminal reads the local target file block, converts the target file block into a file stream, generates a file download response according to the file stream, and sends the file download response to the first terminal if the legality check passes. If the check result is that the legality check fails, the second terminal rejects the file transmission request of the first terminal.
[0115] S405, obtaining the file download response returned by the target second terminal, and obtaining the file download state corresponding to the file download request according to the file download response.
[0116] For example, if the target second terminal rejects the file download request, it is determined that the file download state is a download failure. If the target second terminal returns a target file block based on the file download request, and the target file block passes the integrity check, it is determined that the file download state is a download success. If the target second terminal returns a target file block based on the file download request, and the target file block does not pass the integrity check, it is determined that the file download state is a download failure.
[0117] Specifically, a file download response returned by the target second terminal is acquired. If the file download response is information rejecting the file download request, it is determined that the file download state is download failure. If the file download response is a file stream of the target file block, integrity check is performed on the target file block according to the file map in the case that the transmission of the target file block is completed. For example, integrity check can be performed on the target file block according to the MD5 value of the corresponding file in the file map. In the case that the integrity check is passed, it is determined that the file download state is download success, and a message that the integrity check is passed is sent to the server. In the case that the integrity check is not passed, it is determined that the file download state is download failure.
[0118] S406, for each target file block, in the case that the file download state is download failure, a file download request is sent to a next target second terminal until the file download state is download success.
[0119] In the above example, in the case that the file block f1 is failed to be downloaded from B1, a file download request is sent to a next target second terminal (i.e. B2) in the terminal list, i.e. returning to perform S404. It should be noted that the step of sending a download request to a target second terminal can be performed concurrently, i.e. for the file blocks f1, f2, … to be acquired, a file download request can be sent to the respective corresponding target second terminal synchronously.
[0120] S407, in the case that the forced remote transmission identifier is true, a response message returned by the server is acquired, wherein the response message contains the target file block.
[0121] S408, in the case that the transmission of the target file block is completed, the target file is obtained by splicing the target file block according to the file map.
[0122] Exemplarily, it is determined whether all target file blocks are downloaded according to the file map, if yes, it is determined that the transmission of the target file is completed. The start and end positions of each target file block are determined according to the file map, and the target file is obtained by splicing the target file block according to the start and end positions.
[0123] The embodiment of the present application provides a file distribution method, which determines whether the target address of file transmission is a server or a terminal device in a local area network according to the download record of the terminal in the local area network, avoids occupying a large number of visiting bandwidth resources of the bank branch, reserves sufficient bandwidth for other services, and guarantees the stability of business handling. Meanwhile, since a large number of file transmissions are performed in the local area network, the concurrent pressure of the file distribution server is greatly reduced, and the service efficiency is improved.
[0124] Figure 5 The flow chart of another file distribution method provided by the embodiment of the present application is as follows, Figure 5As shown, the method comprises:
[0125] S501, the server (server C) splits the original file into a plurality of file blocks of specified size according to the configuration, and generates a file block file map, wherein the file block file map contains the file block start and end position, file block size, file block MD5 value and file block identification ID of each file block.
[0126] Among them, the file map can be a map data used for indexing file blocks. The file block identification is used to uniquely identify the file block.
[0127] S502, the client (terminal A) initiates a file transmission request, wherein the request message includes local area network identification, terminal identification, target file, and forced remote transmission identification.
[0128] Among them, the local area network identification can be the branch identification of the bank branch to which the terminal A belongs, etc. The terminal identification is used to uniquely identify the terminal A. The target file is the file that the terminal A needs to download. The forced remote transmission identification is used to indicate whether the file transmission request of the terminal A meets the remote transmission condition.
[0129] S503, the server (server C) reads the forced remote transmission identification in the file transmission request. If the forced remote transmission identification is true, the server C obtains the locally stored file blocks, and returns them to the terminal A in sequence through a response message. After the transmission of each file block is completed, a database record is inserted to record the association information of the local area network identification, terminal identification and target file block.
[0130] S504, if the forced remote transmission identification is false, whether there is a second terminal (terminal list a) that has downloaded the file block of the target file in the local area network to which the terminal A belongs is judged according to the local area network identification and the target file. The content of the terminal list a includes the terminal identification of each second terminal, the IP information of the terminal in the local area network and the file block identification of the successfully downloaded file block.
[0131] S505, whether the terminal list a is empty is judged. If yes, S506 is executed, otherwise S507 is executed.
[0132] S506, the server C obtains the locally stored file blocks, and returns them to the terminal A in sequence through a response message. After the transmission of each file block is completed, a database record is inserted to record the association information of the local area network identification, terminal identification and target file block.
[0133] S507, the server C notifies the terminal A of the identification information of all terminals in the terminal list a, the IP information of the terminal in the local area network, the file block ID list of the terminal that has been downloaded, the file map and the file transmission task ID through a response message, and generates a file transmission task record to save to the database.
[0134] S508, the terminal A determines the file block f1 that needs to be downloaded according to the response message content and the file atlas, obtains the terminal list (B1, B2, …) of the downloaded file block f1, and sequentially requests the file block f1 from the corresponding second terminal according to the terminal list.
[0135] S509, after receiving the file download request, the terminal B1 generates a verification request according to the terminal identifier of the terminal B1, the file transmission task identifier in the file download request, and the target file block identifier, and sends the verification request to the server C.
[0136] S510, the server C receives the verification request, parses the terminal identifier, the file transmission task identifier, and the target file block identifier from the verification request, matches them with the file transmission record in the database, judges the legality of the file download request according to the matching result, and returns the verification result to the terminal B1.
[0137] S511, the terminal B1 obtains the verification result returned by the server C, if the verification result is false, the file download request of the terminal A is rejected, if the verification result is true, the local target file block is read and converted into a file stream and written into a response message and returned to the terminal A.
[0138] S512, after receiving the file block transmission completion, the terminal A checks the file block integrity according to the file block atlas.
[0139] S513, if the integrity check passes, the terminal A sends a message of passing the integrity check to the server C.
[0140] S514, the server C inserts a database record recording the association information between the local area network identifier, the terminal identifier, and the target file block.
[0141] S515, if the integrity check fails, the terminal A requests f1 from the terminal B2 in the terminal list a.
[0142] It should be noted that the above example lists a file block acquisition method, and the terminal A can also concurrently perform the acquisition operation of all the file blocks that need to be downloaded. For example, the terminal A analyzes that the file blocks f1, f2, f6, f7, and f9 need to be downloaded based on the file atlas, can also determine the terminal list of the downloaded file blocks f1, f2, f6, f7, and f9, concurrently performs the file download request for f1, f2, f6, f7, and f9 based on the terminal list, and realizes the synchronous acquisition of the file blocks f1, f2, f6, f7, and f9.
[0143] S516, after determining that all the file blocks are downloaded according to the file atlas, the terminal A combines all the files into the final target file.
[0144] The embodiment of the present application judges whether there is a terminal B successfully downloading a target file block in the same local area network through the local area network identifier sent by the terminal A, and if there is, informs the terminal A to obtain the target file block from the terminal B which has downloaded the file, thereby saving a large amount of visiting bandwidth resources, and splitting the file into file blocks for transmission, which can enhance the stability of file transmission, speed up the file transmission speed, increase the transmission fault tolerance, increase the local area network file transmission proportion, greatly reduce the concurrent pressure of the file distribution server, and improve the service efficiency.
[0145] Figure 6 A structural block diagram of a file distribution device provided by the embodiment of the present application is provided. The device can execute the file distribution method of the present application, and realizes the file distribution between the bank point equipment and the server by executing the file distribution method. The device can be realized by software and / or hardware, and is usually configured in the server. For example, the server can be a server or a server cluster which plays a role of file distribution. The files in the server are stored in the form of file blocks, and the start and end positions of each file block, the file block storage capacity, the file block verification information and the file block identifier are represented by a file map.
[0146] As shown in the figure, the device comprises a request acquisition module 610, a terminal acquisition module 620, a record sending module 630 and a verification module 640. Figure 6
[0147] The request acquisition module 610 is used for acquiring the file transmission request sent by the first terminal, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier.
[0148] The terminal acquisition module 620 is used for acquiring a second terminal which has downloaded the target file in the same local area network according to the local area network identifier and the target file in the case that the forced remote transmission identifier does not satisfy the remote transmission condition.
[0149] The record sending module 630 is used for sending the file transmission record of the second terminal to the first terminal, wherein the file transmission record comprises a terminal list, a file map and a file transmission task identifier.
[0150] The verification module 640 is used for performing legality verification on the verification request of the second terminal based on the file transmission record, sending the verification result to the second terminal, and indicating the second terminal whether to read the file block of the target file and return to the first terminal through the verification result.
[0151] Optionally, the terminal acquisition module 620 is specifically used for:
[0152] In a case that the forced remote transmission identifier does not satisfy the remote transmission condition, the file transmission completion record is queried according to the local area network identifier and the target file.
[0153] According to the query result, a terminal list of at least one second terminal belonging to the same local area network as the first terminal and having downloaded at least one file block of the target file is determined, wherein the terminal list contains identifier information, a network address and the identifier of the file block that has been downloaded of each second terminal.
[0154] Optionally, the record sending module 630 is specifically configured to:
[0155] The file transmission record of the second terminal is generated according to the identifier information, the network address, the identifier of the file block that has been downloaded on the second terminal, the file graph and the file transmission task identifier of the second terminal, and the file transmission record is sent to the first terminal.
[0156] Optionally, the verification module 640 is specifically configured to:
[0157] The verification request sent by the second terminal is parsed to obtain a terminal identifier, a file transmission task identifier and a file block identifier;
[0158] The terminal identifier, the file transmission task identifier and the file block identifier parsed are matched with the file transmission record;
[0159] If the matching is consistent, it is determined that the verification request passes the legality verification.
[0160] Optionally, the apparatus further includes:
[0161] The record generation module is configured to generate a file transmission completion record according to the local area network identifier corresponding to the current file transmission task, a terminal identifier and a target file block in a case that the integrity verification result sent by the first terminal is a verification pass.
[0162] Optionally, the apparatus further includes:
[0163] The remote transmission module is configured to, after obtaining the file transmission request sent by the first terminal, obtain a target file block and send the target file block to the first terminal in a case that the forced remote transmission identifier satisfies the remote transmission condition or the terminal list is empty.
[0164] Optionally, the apparatus further includes:
[0165] The legality verification module is configured to obtain a verification request sent by the second terminal after receiving a file download request, and determine the legality of the file download request through the verification request, wherein the verification request includes a terminal identifier, a file transmission task identifier and a target file.
[0166] The file distribution device provided by the embodiments of the present application can execute the file distribution method provided by any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of executing the method.
[0167] Figure 7 Another structural block diagram of a file distribution device is provided by the embodiments of the present application. The device can execute the file distribution method of the present application, and realizes the file distribution between the bank point equipment and the server by executing the file distribution method. The device can be realized by software and / or hardware, and is usually configured in an electronic device. For example, the electronic device can be a terminal device in a bank point which needs to download a target file.
[0168] As shown in Figure 7 The device includes a request sending module 710, a record obtaining module 720, a file block request module 730 and a file splicing module 740.
[0169] The request sending module 710 is configured to send a file transmission request to a server, wherein the file transmission request includes a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier.
[0170] The record obtaining module 720 is configured to obtain a file transmission record returned by the server, wherein the file transmission record includes a terminal list, a file map and a file transmission task identifier, and the second terminal is a terminal device which has the same local area network identifier as the file transmission request and has downloaded at least one file block of the target file.
[0171] The file block request module 730 is configured to determine a target file block according to the file map, obtain a target second terminal corresponding to each target file block in the terminal list, and poll the target second terminal to obtain the target file block.
[0172] The file splicing module 740 is configured to splice the target file blocks to obtain the target file according to the file map when the transmission of the target file blocks is completed.
[0173] Optionally, the file block request module 730 is specifically configured to:
[0174] send a file download request to each target second terminal corresponding to the target file block, send a verification request to the server according to the file download request through the target second terminal, and convert the target file block into a file stream according to the verification result, generate a file download response according to the file stream, wherein the verification request includes a terminal identifier, a file transmission task identifier and a target file block.
[0175] obtaining a file download response returned by the target second terminal, and obtaining a file download state corresponding to the file download request according to the file download response;
[0176] For each target file block, if the file download state is download failure, sending a file download request to a next target second terminal until the file download state is download success.
[0177] Optionally, the file splicing module 740 is specifically configured to:
[0178] obtaining a file stream of the target file block by analyzing the file download response;
[0179] reading the file stream into the target file block in turn in a chain form according to the start and end positions of the target file block in the file graph;
[0180] judging whether all target file blocks of the target file are downloaded according to the file graph;
[0181] if yes, splicing the target file blocks to obtain the target file according to the start and end positions.
[0182] Optionally, the apparatus further comprises:
[0183] an integrity checking module configured to perform integrity checking on the target file block according to the file graph when the target file block is transmitted completely;
[0184] sending a message of passing integrity checking to the server when the integrity checking passes.
[0185] Optionally, the file block request module 730 is specifically further configured to:
[0186] determining that the file download state is download failure when the target second terminal rejects the file download request;
[0187] determining that the file download state is download success when the target second terminal returns a target file block based on the file download request and the target file block passes integrity checking;
[0188] determining that the file download state is download failure when the target second terminal returns a target file block based on the file download request and the target file block does not pass integrity checking.
[0189] The file distribution apparatus provided in the embodiments of the present application can execute the file distribution method provided in any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of the execution method.
[0190] Figure 8A structural block diagram of an electronic device is provided for embodiments of the present application. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the present application described and / or claimed in this document.
[0191] As shown in Figure 8 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected in communication with the at least one processor 11, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0192] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0193] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the file distribution method.
[0194] In some embodiments, the file distribution method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, parts or all of the computer program can be loaded and / or installed onto electronic device 10 via, e.g., ROM 12 and / or communication unit 19. When the computer program is loaded onto RAM 13 and executed by processor 11, one or more steps of the file distribution method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the file distribution method by way of other means (e.g., by way of firmware).
[0195] A computer program for implementing the method of the present application can be written in any combination of one or more programming languages. The computer program can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor, implements the functions / operations specified in the flow charts and / or block diagrams. The computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package, partly on a machine and partly on a remote machine or entirely on a remote machine or server.
[0196] In the context of the present application, a computer readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium can be a machine readable signal medium. More specific examples of the machine readable storage medium will include one or more lines of a program of instructions in a transitory signal form, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0197] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0198] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), blockchain network, and the Internet.
[0199] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0200] Figure 9 A structural block diagram of a file distribution system provided by an embodiment of the present application is shown in FIG. 1. As shown in the figure, the system includes: Figure 9
[0201] a server 910 configured to perform the file distribution method provided by an embodiment of the present application;
[0202] a first terminal 920 configured to perform the file distribution method provided by an embodiment of the present application;
[0203] The second terminal 930 is configured to acquire the file download request sent by the first terminal, send an authentication request to the server according to the file download request, and acquire an authentication result returned by the server, wherein the authentication request comprises a terminal identifier, a file transmission task identifier and a target file.
[0204] In a case where the authentication result is authentication pass, the target file block is converted into a file stream, a file download response is generated according to the file stream, and the file download response is sent to the first terminal.
[0205] In a case where the authentication result is authentication fail, the file download request is rejected.
[0206] The embodiment of the present application further provides a computer program product comprising a computer program which, when executed by a processor, implements the file distribution method provided in any embodiment of the present application.
[0207] The computer program product can be written in one or more programming languages or combinations of languages to implement the techniques of the present application, including an object-oriented programming language such as Java, Smalltalk, C++, or a conventional procedural programming language such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0208] Note that the above only describes the preferred embodiments of the present application and the principles of the applied technology. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A file distribution method characterized by, The method is applied to a server, wherein files in the server are stored in the form of file blocks, and the start and end positions, file block storage capacity, file block verification information and file block identification of each file block are represented by a file map, and the method comprises the following steps: Obtaining a file transmission request sent by a first terminal, wherein the file transmission request comprises a local area network identification, a terminal identification, a target file and a forced remote transmission identification; wherein the forced remote transmission identification is used to indicate whether the file transmission request meets a remote transmission condition; when the forced remote transmission identification is false, the file transmission request does not meet the remote transmission condition of directly obtaining file blocks from the server; when the forced remote transmission identification is true, the file transmission request meets the remote transmission condition of directly obtaining file blocks from the server; In the case that the forced remote transmission identification does not meet the remote transmission condition, obtaining a second terminal which has downloaded the target file in the same local area network according to the local area network identification and the target file; Sending a file transmission record of the second terminal to the first terminal, wherein the file transmission record comprises a terminal list, a file map and a file transmission task identification; Based on the file transmission record, performing legality verification on a verification request of the second terminal, and sending a verification result to the second terminal, wherein the verification result is used to indicate whether the second terminal reads file blocks of the target file and returns to the first terminal.
2. The method of claim 1, wherein, The step of obtaining the second terminal which has downloaded the target file in the same local area network according to the local area network identification and the target file in the case that the forced remote transmission identification does not meet the remote transmission condition comprises the following steps: In the case that the forced remote transmission identification does not meet the remote transmission condition, querying a file transmission completion record according to the local area network identification and the target file; According to the query result, determining a terminal list of the second terminal which belongs to the same local area network and has downloaded at least one file block of the target file, wherein the terminal list comprises identification information, a network address and a file block identification of each second terminal.
3. The method of claim 1, wherein, The step of sending the file transmission record of the second terminal to the first terminal comprises the following steps: Generating the file transmission record of the second terminal according to the identification information, the network address, the file block identification which has been downloaded on the second terminal, the file map and the file transmission task identification, and sending the file transmission record to the first terminal.
4. The method of claim 3, wherein, The step of performing legality verification on the verification request of the second terminal based on the file transmission record and sending a verification result to the second terminal comprises the following steps: Analyzing the verification request sent by the second terminal to obtain a terminal identification, a file transmission task identification and a file block identification; Matching the terminal identification, the file transmission task identification and the file block identification obtained by analysis with the file transmission record; If the matching is consistent, it is determined that the verification request passes the legality verification.
5. The method of claim 1, wherein, The method further comprises the following steps: In the case that the integrity verification result sent by the first terminal is a verification pass, generating a file transmission completion record according to the local area network identification, the terminal identification and the target file block corresponding to the current file transmission task.
6. The method of claim 5, wherein, The method further comprises: After obtaining the file transmission request sent by the first terminal, further comprising:
7. The method of claim 1, wherein, In the case that the forced remote transmission identifier meets the remote transmission condition or the terminal list is empty, obtaining the target file block and sending the target file block to the first terminal. Further comprising:
8. A file distribution method characterized by, Obtaining the verification request sent by the second terminal after receiving the file download request, and determining the legitimacy of the file download request through the verification request, wherein the verification request comprises a terminal identifier, a file transmission task identifier and a target file. The method applied to the first terminal, comprising: Sending a file transmission request to the server, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier; wherein the forced remote transmission identifier is used to indicate whether the file transmission request meets the remote transmission condition; when the forced remote transmission identifier is false, the file transmission request does not meet the remote transmission condition of directly obtaining the file block from the server; when the forced remote transmission identifier is true, the file transmission request meets the remote transmission condition of directly obtaining the file block from the server; In the case that the forced remote transmission identifier does not meet the remote transmission condition, obtaining the file transmission record of the second terminal returned by the server, wherein the file transmission record comprises a terminal list, a file graph and a file transmission task identifier, and the second terminal is at least one terminal device which has the same local area network identifier as the file transmission request and has downloaded at least one file block of the target file; According to the file graph, determining the target file block, obtaining the target second terminal corresponding to each target file block in the terminal list, and polling the target second terminal to obtain the target file block; 9. The method of claim 8, wherein, In the case that all the target file blocks are transmitted, splicing the target file blocks according to the file graph to obtain the target file. The polling the target second terminal to obtain the target file block comprises: Respectively sending a file download request to the target second terminal corresponding to each target file block, sending a verification request to the server through the target second terminal according to the file download request, and converting the target file block into a file stream according to the verification result, generating a file download response according to the file stream, wherein the verification request comprises a terminal identifier, a file transmission task identifier and a target file block; Obtaining the file download response returned by the target second terminal, and obtaining the file download state corresponding to the file download request according to the file download response; 10. The method of claim 9, wherein, For each target file block, in the case that the file download state is download failure, sending a file download request to the next target second terminal until the file download state is download success. The splicing the target file blocks according to the file graph to obtain the target file in the case that all the target file blocks are transmitted, comprises: Parsing the file download response to obtain the file stream of the target file block; According to the start and end positions of the target file block in the file graph, reading the file stream into the target file block in the form of a relay; According to the file graph, judging whether all the file blocks of the target file are downloaded completely; If yes, the target file is obtained by splicing the target file blocks according to the start and end positions.
11. The method of claim 9, wherein, Further comprising: In the case that the target file block transmission is completed, integrity check is performed on the target file block according to the file map; In the case that the integrity check is passed, a message indicating that the integrity check is passed is sent to the server.
12. The method of claim 11, wherein, The file download state corresponding to the file download request is obtained according to the file download response, comprising: In the case that the target second terminal rejects the file download request, the file download state is determined as download failure; In the case that the target second terminal returns the target file block based on the file download request and the target file block passes the integrity check, the file download state is determined as download success; In the case that the target second terminal returns the target file block based on the file download request and the target file block does not pass the integrity check, the file download state is determined as download failure.
13. A file distribution apparatus characterized by comprising: Comprising: The server is applied to, the file in the server is stored in the form of file block, and the start and end positions, file block storage capacity, file block verification information and file block identification of each file block are represented by a file map, the device comprises: The request obtaining module is configured to obtain a file transmission request sent by a first terminal, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file and a forced remote transmission identifier; wherein the forced remote transmission identifier is used to indicate whether the file transmission request meets a remote transmission condition; when the forced remote transmission identifier is false, the file transmission request does not meet the remote transmission condition of directly obtaining a file block from the server; when the forced remote transmission identifier is true, the file transmission request meets the remote transmission condition of directly obtaining a file block from the server; The terminal obtaining module is configured to obtain a second terminal having downloaded the target file in the same local area network according to the local area network identifier and the target file in the case that the forced remote transmission identifier does not meet the remote transmission condition. The record sending module is configured to send a file transmission record of the second terminal to the first terminal, wherein the file transmission record comprises a terminal list, a file map and a file transmission task identifier; The check module is configured to perform legality check on a verification request of the second terminal based on the file transmission record, send a check result to the second terminal, and indicate whether the second terminal reads a file block of the target file and returns to the first terminal through the check result.
14. The apparatus of claim 13, wherein, The record sending module is specifically configured to: generate the file transmission record of the second terminal according to the identifier information, the network address, the file block identifier having been downloaded on the second terminal, the file map and the file transmission task identifier, and send the file transmission record to the first terminal.
15. The apparatus of claim 14, wherein, The check module is specifically configured to: analyze the verification request sent by the second terminal to obtain a terminal identifier, a file transmission task identifier and a file block identifier; match the terminal identifier, the file transmission task identifier and the file block identifier obtained by analysis with the file transmission record; If the match is consistent, it is determined that the verification request passes the legality check.
16. A file distribution apparatus characterized by comprising: The application is applied to a first terminal, and the device comprises: The request sending module is configured to send a file transmission request to a server, wherein the file transmission request comprises a local area network identifier, a terminal identifier, a target file, and a forced remote transmission identifier; the forced remote transmission identifier is used to indicate whether the file transmission request meets a remote transmission condition; when the forced remote transmission identifier is false, the file transmission request does not meet the remote transmission condition of directly obtaining a file block from the server; when the forced remote transmission identifier is true, the file transmission request meets the remote transmission condition of directly obtaining a file block from the server; The record obtaining module is configured to obtain a file transmission record of a second terminal returned by the server in a case where the forced remote transmission identifier does not meet the remote transmission condition, wherein the file transmission record comprises a terminal list, a file graph, and a file transmission task identifier; the second terminal is a terminal device that has the same local area network identifier as the file transmission request and has downloaded at least one file block of the target file; The file block request module is configured to determine a target file block according to the file graph, obtain a target second terminal corresponding to each target file block in the terminal list, and poll the target second terminal to obtain the target file block; The file concatenation module is configured to concatenate the target file blocks to obtain the target file according to the file graph in a case where the target file blocks are all transmitted.
17. The apparatus of claim 16, wherein, The file concatenation module is specifically configured to: analyze the file download response to obtain a file stream of the target file block; read the file stream into the target file block in a relay form according to start and end positions of the target file block in the file graph; determine whether all the target file blocks are downloaded according to the file graph; if yes, concatenate the target file blocks according to the start and end positions to obtain the target file.
18. An electronic device, comprising: The computer program is stored in the memory and executable in the processor, and when the processor executes the computer program, the file distribution method in any one of claims 1-7 is implemented, or when the processor executes the computer program, the file distribution method in any one of claims 8-12 is implemented.
19. A file distribution system characterized by, The computer program is stored in the memory and executable in the processor, and when the processor executes the computer program, the file distribution method in any one of claims 1-7 is implemented, or when the processor executes the computer program, the file distribution method in any one of claims 8-12 is implemented. The computer program is stored in the memory and executable in the processor, and when the processor executes the computer program, the file distribution method in any one of claims 1-7 is implemented, or when the processor executes the computer program, the file distribution method in any one of claims 8-12 is implemented. The computer program is stored in the memory and executable in the processor, and when the processor executes the computer program, the file distribution method in any one of claims 1-7 is implemented, or when the processor executes the computer program, the file distribution method in any one of claims 8-12 is implemented. 20. A computer readable storage medium having stored thereon a computer program, characterized in that, The program, when executed by the processor, implements the file distribution method as claimed in any one of claims 1-12.
21. A computer program product comprising a computer program, characterized in that, The computer program, when executed by the processor, implements the file distribution method as claimed in any one of claims 1-12.
Citation Information
Patent Citations
A method and device for data download
CN101146107A
File transmission method, device and system and computer storage medium
CN109995876A
Resource file acquisition method and device, equipment, medium and product
CN115242775A