File transmission method, device, electronic device and storage medium
By utilizing multiple available intermediate devices to transmit different files in parallel or adjust the transmission sequence during file transfer, the problem of slow file transfer speed and easy failure is solved, and faster transmission speed and higher success rate are achieved.
Patent Information
- Application Number
- CN202211192416.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-09-28
AI Technical Summary
During the existing file transfer process, especially when there are many files or a single file is large, the transfer speed is slower and it is easy to get stuck at a certain file, resulting in the transmission failure.
By obtaining the number of devices and the number of files to be transferred for at least two available intermediate devices, determining the parallel transmission task, and using different available intermediate devices to transmit different files in parallel or adjusting the transmission sequence, ensuring that each device has a corresponding transmission task.
Improves file transfer speed, reduces total transfer time, and improves file transfer success rate through repeated transfers.
Smart Images

Figure CN115550348B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a file transmission method, device, electronic device, and storage medium. Background Art
[0002] The Secure File Transfer Protocol (SSH File Transfer Protocol, SFTP) is a remote file transfer method based on the Secure Shell Protocol (SSH).
[0003] In the existing file transfer process, a local machine establishes a communication connection with a remote machine and then transfers files through SFTP. However, during this process, when there are many files or a single file is large, the transfer speed is slow and may get stuck at one file, resulting in transfer failure. Summary of the Invention
[0004] In view of this, embodiments of the present application provide a file transmission method, device, electronic device, and storage medium to at least solve the problems of slow file transmission speed and easy transmission failure.
[0005] In a first aspect, an embodiment of the present application provides a file transmission method, comprising:
[0006] In response to the file transfer instruction, determining at least two files to be transferred on the first device;
[0007] Obtaining the number of at least two available intermediate devices and the number of the at least two files to be transferred;
[0008] If the number of files is greater than or equal to the number of devices, obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and different available intermediate devices have different at least one transmission task, or the different available intermediate devices have the same at least one transmission task but a different transmission order of the at least one transmission task, and the at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively;
[0009] The at least one transmission task is executed in sequence by the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed.
[0010] In a second aspect, an embodiment of the present application further provides a file transmission method, comprising:
[0011] In response to the file transfer instruction, determining at least two files to be transferred on the first device;
[0012] Obtaining the number of at least two available intermediate devices and the number of the at least two files to be transferred;
[0013] If the number of files is less than the number of devices, obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and at least one transmission task for at least the number of files and the number of available intermediate devices is different, or the at least one transmission task is the same but the transmission order of the at least one transmission task is different, or each available intermediate device transmits one transmission task from the number of files, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively;
[0014] The at least one transmission task is executed in sequence by the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed.
[0015] In a third aspect, an embodiment of the present application further provides a file transmission device, including:
[0016] a determining module, configured to determine, in response to a file transfer instruction, at least two files to be transferred on the first device;
[0017] An acquisition module, configured to acquire the number of at least two available intermediate devices and the number of the at least two files to be transferred;
[0018] The acquisition module is further configured to, if the number of files is greater than or equal to the number of devices, acquire at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transferred, and different available intermediate devices have different at least one transmission task, or the different available intermediate devices have the same at least one transmission task but a different transmission order of the at least one transmission task, and the at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively;
[0019] An execution module is used to execute the at least one transmission task in sequence through the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed.
[0020] In a fourth aspect, an embodiment of the present application further provides a file transmission device, including:
[0021] a determining module, configured to determine, in response to a file transfer instruction, at least two files to be transferred on the first device;
[0022] An acquisition module, configured to acquire the number of at least two available intermediate devices and the number of the at least two files to be transferred;
[0023] The acquisition module is further configured to, if the number of files is less than the number of devices, acquire at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transferred, and at least one transmission task for at least the number of files and the number of available intermediate devices is different, or the at least one transmission task is the same but the transmission order of the at least one transmission task is different, or each available intermediate device transmits one transmission task from the number of files, and at least two of the available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively;
[0024] An execution module is used to execute the at least one transmission task in sequence through the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed.
[0025] In the fifth aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus, and the processor executes the machine-readable instructions to execute the file transfer method described in any one of the first and second aspects.
[0026] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the file transfer method described in any one of the first and second aspects is executed.
[0027] The present application provides a file transfer method, device, electronic device and storage medium, wherein the method includes: obtaining the device number of at least two available intermediate devices and the file number of at least two files to be transferred, and when the file number is greater than or equal to the device number, obtaining at least one transmission task for each available intermediate device, and then executing at least one transmission task in sequence through the available intermediate devices to transfer the file to be transferred corresponding to at least one transmission task from the first device to the second device, wherein each transmission task corresponds to a file to be transferred, and at least one transmission task of different available intermediate devices is different, so that different available intermediate devices can transmit different files in parallel, thereby improving the transmission speed and reducing the total transmission time, or at least one transmission task of different available intermediate devices is the same but the transmission order of at least one transmission task is different, so that different available intermediate devices can transmit different files in parallel, thereby improving the transmission speed and reducing the total transmission time, and since the transmission tasks transmitted by different available intermediate devices are the same, the file transmission success rate can be improved through repeated transmission.
[0028] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0030] Figure 1 Schematic diagram of the file transfer process provided in this application embodiment Figure 1 ;
[0031] Figure 2 Schematic diagram of the file transfer process provided in this application embodiment Figure 2 ;
[0032] Figure 3 Schematic diagram of the file transfer process provided in this application embodiment Figure 3 ;
[0033] Figure 4 Schematic diagram of the file transfer process provided in this application embodiment Figure 4 ;
[0034] Figure 5 Schematic diagram of the file transfer process provided in this application embodiment Figure 5 ;
[0035] Figure 6 Schematic diagram of the file transfer process provided in this application embodiment Figure 6 ;
[0036] Figure 7 A schematic diagram of the structure of the file transmission device provided in the embodiment of the present application Figure 1 ;
[0037] Figure 8 A schematic diagram of the structure of the file transmission device provided in the embodiment of the present application Figure 2 ;
[0038] Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.
[0040] In view of the problem that in the prior art, when there are many files or a single file is large, the Secure File Transfer Protocol (SSH File Transfer Protocol, SFTP) is used to connect the local device and the remote device. Since the local device and the remote device have only one connection line, the transmission speed is slow and there is a possibility of getting stuck at a certain file, resulting in transmission failure, the present application provides a file transfer method that transmits different files in parallel through different available intermediate devices, thereby improving the transmission speed and reducing the total transmission time. It also provides a file transfer guarantee mechanism that can improve the file transfer success rate through repeated transmission.
[0041] The following combination Figures 1-4 The embodiment illustrates a file transmission method provided by this application.
[0042] Figure 1 Schematic diagram of the file transfer process provided in this application embodiment Figure 1 The execution subject of this embodiment may be a second device, such as a mobile phone, a tablet computer, a laptop computer, or other device with data processing capabilities.
[0043] like Figure 1 As shown, the method may include:
[0044] S101: In response to a file transfer instruction, determine at least two files to be transferred on a first device.
[0045] The user can input a file transfer instruction on the second device, and the second device responds to the file transfer instruction and determines at least two files to be transferred on the first device, wherein the first device is a local device and the second device is a remote device; or the first device is a remote device and the second device is a local device.
[0046] In some embodiments, the second device may request the first device to list the file identifiers of at least two files to be transferred in response to a file transfer instruction. For example, the second device may send an identifier acquisition instruction for at least two files to be transferred to the first device, and the first device may return the identifiers of at least two files to be transferred on the first device to the second device in response to the identifier acquisition instruction. Alternatively, the second device may actively pull the identifiers of at least two files to be transferred from the first device. In this way, the second device can obtain the file identifiers of the files to be transferred.
[0047] S102: Obtain the device quantity of at least two available intermediate devices and the file quantity of at least two files to be transmitted.
[0048] S103: If the number of files is greater than or equal to the number of devices, obtain at least one transmission task from each available intermediate device.
[0049] The at least two available intermediate devices are intermediate devices that are communicatively connected to the first device and the second device respectively.
[0050] The second device obtains the device number of at least two available intermediate devices and the file number of at least two files to be transferred, and determines whether the file number is greater than or equal to the device number. If the file number is greater than the device number, at least one transmission task for each available intermediate device can be obtained, and each transmission task corresponds to a file to be transferred, that is, each transmission task is a transmission task for the corresponding file.
[0051] At least one transmission task of different available intermediate devices is different, or at least one transmission task of different available intermediate devices is the same but the transmission order of at least one transmission task is different.
[0052] Among them, at least one transmission task of different available intermediate devices is different, which means that the transmission tasks of different available intermediate devices are different, that is, the files transmitted by different available intermediate devices are different; at least one transmission task of different available intermediate devices is the same but the transmission order of at least one transmission task is different, which means that the transmission tasks of different available intermediate devices are the same, but the transmission order of the files corresponding to the transmission tasks is different.
[0053] S104: Execute at least one transmission task in sequence through an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0054] At least one transmission task of the available intermediate device is executed in sequence by the available intermediate device to transmit the file to be transmitted corresponding to the at least one transmission task from the first device to the second device, that is, each available intermediate device transmits the corresponding file in parallel until at least two files to be transmitted are transmitted, and then the transmission can be stopped.
[0055] In some embodiments, the second device may send a task execution instruction to the available intermediate device, so that the available intermediate device executes the corresponding transmission task and transmits the corresponding file to be transmitted from the first device to the second device.
[0056] In the file transfer method of this embodiment, at least one transmission task of different available intermediate devices is different, or at least one transmission task of different available intermediate devices is the same but the transmission order of at least one transmission task is different. In this way, different available intermediate devices transmit different files in parallel, which improves the transmission speed and reduces the total transmission time. Different available intermediate devices transmit the same file in parallel, which reduces the total transmission time and, through repeated transmission, can improve the success rate of file transmission.
[0057] In an optional embodiment, the method may further include:
[0058] After the transmission of at least two files to be transmitted is completed, the uncompleted transmission task of at least one transmission task of the available intermediate device is deleted.
[0059] Because each available intermediate device performs file transfers in parallel, each available intermediate device does not need to consider the files being transferred by other available intermediate devices. For the second device, after the transfer of at least two pending files is complete, the uncompleted transfer task of at least one available intermediate device can be deleted to save memory space.
[0060] It should be noted that the files obtained after each successful transmission task may have a suffix, such as the tmp suffix. For example, intermediate devices b1 and b3 can transmit f1 at the same time. b3 completes the transmission first. At this time, b3 is transmitting f2. b2 has already completed the transmission of f2 and is also transmitting f1. Then, the data directory of the second device may have the following five files: (1) f1.b1.tmp, (2) f1.b3, (3) f2.b2, (4) f1.b2.tmp, and (5) f2.b3.tmp.
[0061] In the process of receiving each file, if it is determined that f1, f2, and f2 have all been transmitted, the unfinished transmission tasks will be deleted. The files of the unfinished transmission tasks can be temporary files with the tmp suffix, and the second device can also rename the files in the data directory, for example, rename f1.b3 to f1 and rename f2.b2 to f2.
[0062] Of course, if it is detected that the second device has received all the files to be transmitted, the second device may also stop requesting the available intermediate device to close the communication connection with the first device, as well as the communication connection between the second device and the available intermediate device.
[0063] The following combination Figure 2 The embodiment describes a method for obtaining at least one transmission task from each available intermediate device.
[0064] Figure 2 Schematic diagram of the file transfer process provided in this application embodiment Figure 2 ,like Figure 2 As shown, obtaining at least one transmission task from each available intermediate device includes:
[0065] S201: The identifiers of at least two available intermediate devices and the identifiers of at least two files to be transmitted are cycled in sequence to obtain a device identifier sorting and a file identifier sorting.
[0066] If the number of files is greater than or equal to the number of devices, the identifiers of at least two available intermediate devices may be cycled in sequence to obtain a device identifier sort, and the identifiers of at least two files to be transferred may be cycled in sequence to obtain a file identifier sort.
[0067] For example, if the identifiers of at least two intermediate devices are b1, b2, and b3, and the identifiers of at least two files to be transferred are f1 and f2, the device identifier sorting can be b1, b2, b3, b1, b2, b3, b1, b2, b3..., and the file identifier sorting can be f1, f2, f1, f2, f1, f2...
[0068] S202: Determine the ratio of the number of files to the number of devices.
[0069] S203: If the ratio of the number of files to the number of devices is a fraction, the device identification order and the file identification order are matched in sequence to obtain a first number of transmission tasks of available intermediate devices.
[0070] Calculate the ratio of the number of files to the number of devices. If the ratio is a fraction, match the device identification sort and the file identification sort in sequence to obtain a first number of transmission tasks for available intermediate devices, where the first number is the numerator of the target ratio, and the target ratio is the ratio of the number of files to the greatest common divisor of the number of files and the number of devices.
[0071] The first number of transmission tasks of different available intermediate devices is different, or the first number of transmission tasks of different available intermediate devices is the same but the transmission order of the first number of transmission tasks of different available intermediate devices is different.
[0072] In some embodiments, matching the device identification sorting and the file identification sorting may be matching the device identifications in the device identification sorting and the file identifications in the file identification sorting, and each transmission task corresponds to one device identification and one file identification.
[0073] As shown in Table 1, Table 1 is a matching table 1 of device identification sorting and file identification sorting. The number of files is 3, the number of devices is 2, the identifications of at least two available intermediate devices are b1 and b2, and the identifications of at least two files to be transferred are f1, f2, and f3. The device identification sorting can be b1, b2, b1, b2, b1, b2..., and the file identification sorting can be f1, f2, f3, f1, f2, f3, f1, f2, f3...
[0074] In this example, the ratio of the number of files to the number of devices, 3 / 2, is a fraction, so the device identification sort and the file identification sort are matched in turn to obtain the first number of transmission tasks for available intermediate devices, where the greatest common divisor of the number of files and the number of devices is 1, and the target ratio is the ratio of the number of files, 3, to the greatest common divisor, 1, that is, 3. The first number is the numerator of the target ratio, 3, indicating that there are 3 transmission tasks for the available intermediate devices b1 and b2 respectively, and the transmission tasks of b1 are f1, f3, and f2, and the transmission tasks of b2 are f2, f1, and f3.
[0075] File ID sorting Device ID sorting f1 b1 f2 b2 f3 b1 f1 b2 f2 b1 f3 b2 f1 b1 f2 b2 … …
[0076] Table 1
[0077] In the example of Table 1, the first number of transmission tasks of different available intermediate devices are the same, but the transmission order of the first number of transmission tasks of different available intermediate devices is different, that is, the transmission tasks of b1 and b2 are the same, but the transmission order of b1 is f1, f3, f2, and the transmission order of b2 is f2, f1, f3.
[0078] As shown in Table 2, Table 2 is the second matching table of device identification sorting and file identification sorting. The number of files is 6, the number of devices is 4, the identifications of at least two available intermediate devices are b1, b2, b3, b4, and the identifications of at least two files to be transferred are f1, f2, f3, f4, f5, f6. The device identification sorting can be b1, b2, b3, b4, b1, b2, b3, b4..., and the file identification sorting can be f1, f2, f3, f4, f5, f6, f1, f2, f3, f4, f5, f6...
[0079] In this example, the ratio of the number of files to the number of devices, 6 / 4, is a fraction, so the device identification sort and the file identification sort are matched in turn to obtain the first number of transmission tasks for available intermediate devices, where the greatest common divisor of the number of files and the number of devices is 2, and the target ratio is the ratio of the number of files, 6, to the greatest common divisor, 2, that is, 3. The first number is the numerator of the target ratio, 3, indicating that there are 3 transmission tasks for the available intermediate devices b1, b2, b3, and b4 respectively. The transmission tasks of b1 are f1, f5, and f3; the transmission tasks of b2 are f2, f6, and f4; the transmission tasks of b3 are f3, f1, and f5; and the transmission tasks of b4 are f4, f2, and f6.
[0080] File ID sorting Device ID sorting f1 b1 f2 b2 f3 b3 f4 b4 f5 b1 f6 b2 f1 b3 f2 b4 f3 b1 f4 b2 f5 b3 f6 b1 … …
[0081] Table 2
[0082] In the example of Table 2, the first number of transmission tasks of different available intermediate devices is different, or the first number of transmission tasks of different available intermediate devices is the same but the transmission order of the first number of transmission tasks of different available intermediate devices is different, that is, the transmission tasks of b1 and b3 are the same, but the transmission order of b1 is f1, f5, f3, and the transmission order of b3 is f3, f1, f5; b2 and b4 are similar; the transmission tasks of b1 and b2 are different; b3 and b4 are similar.
[0083] S204: If the ratio of the number of files to the number of devices is a positive integer, the device identification sort and the file identification sort are matched in sequence to obtain a second number of transmission tasks of available intermediate devices.
[0084] Calculate the ratio of the number of files to the number of devices. If the ratio is a positive integer, match the device identification sort and the file identification sort in sequence to obtain a second number of transmission tasks for available intermediate devices, where the second number is the ratio of the number of files to the number of devices.
[0085] The second number of transmission tasks is different for different available intermediate devices.
[0086] In some embodiments, each transmission task corresponds to a device identifier and a file identifier, indicating that an available intermediate device corresponding to the device identifier is used to transmit the file corresponding to the file identifier from the first device to the second device.
[0087] As shown in Table 3, Table 3 is the matching table 3 of device identification sorting and file identification sorting. The number of files is 6, the number of devices is 2, the identifications of at least two available intermediate devices are b1 and b2, and the identifications of at least two files to be transferred are f1, f2, f3, f4, f5, f6... The device identification sorting can be b1, b2, b1, b2, b1, b2..., and the file identification sorting can be f1, f2, f3, f4, f5, f6, f1, f2, f3, f4, f5, f6...
[0088] In this example, the ratio of the number of files to the number of devices, 6 / 2, is a positive integer. The device identification sorting and the file identification sorting are matched in sequence to obtain the second number of transmission tasks for the available intermediate devices, where the second number is the ratio of the number of files to the number of devices, that is, 6 / 2, indicating that there are 3 transmission tasks for the available intermediate devices b1 and b2 respectively, and the transmission tasks of b1 are f1, f3, and f5, and the transmission tasks of b2 are f2, f4, and f6.
[0089] File ID sorting Device ID sorting f1 b1 f2 b2 f3 b1 f4 b2 f5 b1 f6 b2 … …
[0090] Table 3
[0091] In this example, the second number of transmission tasks of different available intermediate devices is different, that is, the transmission tasks of b1 and b2 are different.
[0092] The following combination Figure 3 The embodiment describes a method for obtaining at least one transmission task from each available intermediate device.
[0093] Figure 3 Schematic diagram of the file transfer process provided in this application embodiment Figure 3 ,like Figure 3 As shown, before obtaining the number of devices of at least two available intermediate devices and the number of files of at least two files to be transferred, the method may further include:
[0094] S301: In response to a file transfer instruction, determine an identifier of an intermediate device from a configuration file of a first device or a second device.
[0095] S302: The intermediate devices corresponding to the identifiers that have successfully established communication connections with the first device and the second device, respectively, are selected as at least two available intermediate devices.
[0096] The identifier of the intermediate device may be pre-specified in the configuration file of the first device or the configuration of the second device, such as specifying the intermediate devices bridge_1, bridge_2, bridge, and bridge_n in CONFIG.
[0097] In response to a file transfer instruction, the identifier of the intermediate device can be determined from the configuration file of the first device or the second device, and a communication connection can be established between the first device and the second device, respectively. During this process, there may be an intermediate device with which the connection fails. Therefore, it is necessary to select the intermediate devices corresponding to the identifiers that have successfully established a communication connection with the first device and the second device, respectively, as at least two available intermediate devices. In this way, file transfer can be carried out when the communication connection is successfully established, avoiding the inability to perform file transfer due to communication failures with the intermediate devices.
[0098] In some embodiments, the first device or the second device is a local device.
[0099] Taking the first device as a local device and the second device as a remote device as an example, the above communication connection can be implemented using the Secure Shell Protocol (SSH). The SSH protocol allows the execution of remote commands. Then, the following command can be executed on the local device:
[0100] ssh-h b1 #local connection b1
[0101] ssh-h b1-c "ssh-h remote" #local connects to the intermediate device b1 and requires b1 to execute the connection remote
[0102] Of course, you can also pre-write some auxiliary scripts and store them on the local device, and call them through SSH between the local device and the intermediate device. The communication between these scripts and the remote device is no longer limited to the SSH protocol, but can also be other protocols such as Hypertext Transfer Protocol (HTTP) and Remote Procedure Call (RPC). For example, write a Python script to connect and transfer files:
[0103] ssh -h b1 -c "python operate.py connect remote" #Connect to b1 and require b1 to execute the python script to connect to the remote device
[0104] The local device controls at least two available intermediate devices to establish communication connections with the local device and the remote device respectively. The communication connections can be implemented using the Secure Shell Protocol (SSH). The SSH protocol allows the execution of remote commands. The following commands can be executed on the local device:
[0105] ssh-h b1 #local connection b1
[0106] ssh-h b1-c "ssh-h remote" #local connects to b1 and asks b1 to connect to remote
[0107] Of course, you can also pre-write some auxiliary scripts and store them on the local device, and call them through SSH between the local device and the intermediate device. The communication between these scripts and the remote device is no longer limited to the SSH protocol, but can also be other protocols such as Hypertext Transfer Protocol (HTTP) and Remote Procedure Call (RPC). For example, write a Python script to connect and transfer files:
[0108] ssh -h b1 -c "python operate.py connect remote" #Connect to b1 and require b1 to execute the python script to connect to the remote device
[0109] In an optional embodiment, at least two available intermediate devices can be controlled to establish communication connections with the second device through at least one network card of the second device; at least two intermediate devices can be controlled to establish communication connections with the first device through at least one network card of the first device.
[0110] The second device may have at least one network card, and at least two available intermediate devices may respectively establish communication with the local device through at least one network card of the second device, and establish a communication connection with the first device through at least one network card of the first device. For example, b1 may establish a communication connection with the second device through the second network card of the second device, and establish a communication connection with the first remote device through the third network card of the first device. b2 may establish a communication connection with the second device through the first network card of the local device, and establish a communication connection with the first device through the first network card of the first device. After establishing a communication connection through at least one network card, the network card that establishes the communication connection may be used for file transfer, thereby reducing the device load and improving the transmission speed and transmission success rate.
[0111] The following combination Figure 4 The embodiment describes a method for obtaining a file to be transmitted.
[0112] Figure 4 Schematic diagram of the file transfer process provided in this application embodiment Figure 4 ,like Figure 4 As shown, in response to the file transfer instruction, determining at least two files to be transferred on the first device includes:
[0113] S401: In response to a file transfer instruction, obtain files in a specified directory on the first device according to identification information of the specified directory on the first device.
[0114] S402: Obtain at least two files to be transferred according to the files in the specified directory on the first device.
[0115] The file transfer instruction includes identification information of a specified directory on the first device. In response to the file transfer instruction, files in the specified directory can be obtained from the first device based on the identification information of the specified directory on the first device, and at least two files to be transferred can be obtained from the files in the specified directory on the first device, wherein the files in the specified directory on the first device include the at least two files to be transferred.
[0116] And / or, the file transfer instruction further includes: identification information of a specified directory on the second device. The method may further include:
[0117] S403: Store the at least two files to be transferred that have been transferred in the designated directory on the second device according to the identification information of the designated directory on the second device.
[0118] The file transfer instruction may further include identification information of a designated directory on the second device, and the at least two files to be transferred that have been transferred may be stored in the designated directory on the second device.
[0119] Taking the first device as the local device and the second device as the remote device as an example, the file transfer instruction is downloadremote: / data local: / data, where download remote means downloading files from the remote device, remote is the identification information of the remote device, data local means transferring files from the data directory on the remote device to the local device, and data means downloading files to the data directory on the local device.
[0120] The following combination Figure 5-Figure 5 The embodiment illustrates another file transmission method provided by the present application.
[0121] Figure 5 Schematic diagram of the file transfer process provided in this application embodiment Figure 5The execution subject of this embodiment may be a second device, such as a mobile phone, a tablet computer, a laptop computer, or other device with data processing capabilities.
[0122] like Figure 5 As shown, the method may include:
[0123] S501: In response to a file transfer instruction, determine at least two files to be transferred on a first device.
[0124] S502: Obtain the device quantity of at least two available intermediate devices and the file quantity of at least two files to be transferred.
[0125] The implementation process of steps S501-S502 can be found in the above Figure 1 Steps S101-S102 in the embodiment will not be described in detail here.
[0126] S503: If the number of files is less than the number of devices, obtain at least one transmission task from each available intermediate device.
[0127] The at least two available intermediate devices are intermediate devices that are communicatively connected to the first device and the second device respectively.
[0128] If the number of files is less than the number of devices, at least one transmission task may be obtained for each available intermediate device, each transmission task corresponding to a file to be transmitted, that is, each transmission task is a transmission task for a corresponding file.
[0129] There is at least one different transmission task of at least the number of available intermediate devices, or at least one transmission task is the same but the transmission order of at least one transmission task is different, or each available intermediate device transmits one transmission task out of the number of available intermediate devices, and there are at least different transmission tasks transmitted by the number of available intermediate devices.
[0130] Among them, there is at least one different transmission task of at least the file number of available intermediate devices, which means that the transmission tasks of the file number of available intermediate devices are different, that is, the files transmitted by the file number of available intermediate devices are different; there is at least one identical transmission task of at least the file number of available intermediate devices but a different transmission order of at least one transmission task, which means that the transmission tasks of the file number of available intermediate devices are the same but the transmission order is different; each available intermediate device transmits one transmission task among the file number of transmission tasks, and there are at least different transmission tasks transmitted by the file number of available intermediate devices, which means that each available intermediate device transmits a file, and the files transmitted by the file number of available intermediate devices are different.
[0131] S504: Execute at least one transmission task in sequence through an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0132] At least one transmission task of the available intermediate device is executed in sequence by the available intermediate device to transmit the file to be transmitted corresponding to the at least one transmission task from the first device to the second device, that is, each available intermediate device transmits the corresponding file in parallel until at least two files to be transmitted are transmitted, and then the transmission can be stopped.
[0133] In the file transfer method of this embodiment, at least one of the available intermediate devices has at least one different transmission task, or at least one of the available intermediate devices has at least one identical transmission task but a different transmission order, or each available intermediate device transmits one of the available intermediate devices, and at least one of the available intermediate devices transmits different tasks. In this way, different available intermediate devices transmit different files in parallel, improving transmission speed and reducing total transmission time. Furthermore, different available intermediate devices transmit the same file in parallel, reducing total transmission time and, through repeated transmission, improving the success rate of file transfers.
[0134] The following combination Figure 6 The embodiment describes another method for obtaining at least one transmission task from each available intermediate device.
[0135] Figure 6 Schematic diagram of the file transfer process provided in this application embodiment Figure 6 ,like Figure 6 As shown, obtaining at least one transmission task from each available intermediate device includes:
[0136] S601: Identifications of at least two available intermediate devices and at least two files to be transmitted are cycled in sequence to obtain a device identification sort and a file identification sort.
[0137] S602: Determine the ratio of the number of devices to the number of files.
[0138] The implementation process of steps S601-S602 can be found in the above Figure 2 Steps S201-S202 in the embodiment are not described in detail here.
[0139] S603: If the ratio of the number of devices to the number of files is a fraction, the device identification sort and the file identification sort are matched in sequence to obtain a third number of transmission tasks of available intermediate devices.
[0140] The at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device respectively.
[0141] Calculate the ratio of the number of devices to the number of files. If the ratio of the number of files to the number of devices is a fraction, match the device identification sort and the file identification sort in turn to obtain a third number of transmission tasks for available intermediate devices. Each transmission task corresponds to a device identification and a file identification, indicating that the file corresponding to the transmission file identification is transmitted from the first device to the second device through the available intermediate device corresponding to the device identification.
[0142] The third number is a ratio of the number of files to the second ratio, and the second ratio is the greatest common divisor of the number of devices and the number of files.
[0143] Among at least two available intermediate devices, at least a third number of transmission tasks of the available intermediate devices that is the number of files is different, or the third number of transmission tasks is the same but the transmission order of the third number of transmission tasks is different.
[0144] As shown in Table 4, Table 4 is a matching table 4 of device identification sorting and file identification sorting. The number of files is 2, the number of devices is 3, the identifications of at least two available intermediate devices are b1, b2, and b3, and the identifications of at least two files to be transferred are f1 and f2. The device identification sorting can be b1, b2, b3, b1, b2, b3, ..., and the file identification sorting can be f1, f2, f1, f2, f1, f2 ...
[0145] If the ratio of the number of devices to the number of files, 3 / 2, is a fraction, then the device identification sort and the file identification sort are matched in turn to obtain the third number of transmission tasks of the available intermediate devices, where the target common divisor is the greatest common divisor of the number of devices and the number of files, that is, 1, and the third number is the ratio of the number of files to the target common divisor, that is, 2 / 1, which is equal to 2.
[0146] File ID sorting Device ID sorting f1 b1 f2 b2 f1 b3 f2 b1 f1 b2 f2 b3 … …
[0147] Table 4
[0148] In the example of Table 4, there are at least three identical transmission tasks in at least two available intermediate devices, but the transmission order of the third identical transmission tasks is different, that is, there are at least two available intermediate devices with two identical transmission tasks, but the transmission order of the two transmission tasks is different (such as b1 and b2 have the same transmission tasks but different transmission orders, b1's transmission tasks are f1, f2, and b2's transmission tasks are f2, f1).
[0149] As shown in Table 5, Table 5 is a matching table 4 of device identification sorting and file identification sorting. The number of files is 4, the number of devices is 6, the identifications of at least two available intermediate devices are b1, b2, b3, b4, b5, b6, and the identifications of at least two files to be transferred are f1, f2, f3, f4. The device identification sorting can be b1, b2, b3, b4, b5, b6, b1, b2, b3, b4, b5, b6..., and the file identification sorting can be f1, f2, f3, f4, f1, f2, f3, f4...
[0150] The ratio of the number of devices to the number of files, 6 / 4, is a fraction. Then the device identification sorting and the file identification sorting are matched in turn to obtain the third number of transmission tasks of the available intermediate devices. The target common divisor is the greatest common divisor of the number of devices and the number of files, that is, 2. The third number is the ratio of the number of files to the target common divisor, that is, 4 / 2, which is equal to 2.
[0151] File ID sorting Device ID sorting f1 b1 f2 b2 f3 b3 f4 b4 f1 b5 f2 b6 f3 b1 f4 b2 f1 b3 f2 b4 f3 b5 f4 b6 … …
[0152] Table 5
[0153] In the example of Table 5, among at least two available intermediate devices, there are at least a third number of the number of files and available intermediate devices with different transmission tasks, that is, there are at least 4 available intermediate devices with 2 different transmission tasks (such as b1-b4d have different transmission tasks, b1's transmission tasks are f1 and f3, b2's transmission tasks are f2 and f4, b3's transmission tasks are f3 and f1, and b4's transmission tasks are f4 and f2).
[0154] S604: If the ratio of the number of devices to the number of files is a positive integer, the device identification order and the file identification order are matched in sequence to obtain a transmission task of an available intermediate device.
[0155] If the ratio of the number of devices to the number of files is a positive integer, the device identification sort and the file identification sort are matched in sequence to obtain a transmission task for an available intermediate device, and each available intermediate device transmits one transmission task from the number of transmission tasks for the number of files.
[0156] There are at least two available intermediate devices in which at least one transmission task transmitted by the intermediate devices is different in the number of files.
[0157] As shown in Table 6, Table 6 is a matching table six of device identification sorting and file identification sorting. The number of files is 2, the number of devices is 4, the identifications of at least two available intermediate devices are b1, b2, b3, b4, and the identifications of at least two files to be transferred are f1 and f2. The device identification sorting can be b1, b2, b3, b4, b1, b2, b3, b4..., and the file identification sorting can be f1, f2, f1, f2...
[0158] In this example, the ratio of the number of devices to the number of files is a positive integer of 2. The device identification sorting and the file identification sorting are matched in turn to obtain one transmission task of the available intermediate device among the number of file transmission tasks, that is, the available intermediate device is used to transmit one transmission task of the number of file transmission tasks.
[0159] File ID sorting Device ID sorting f1 b1 f2 b2 f1 b3 f2 b4 … …
[0160] Table 6
[0161] At least two of the available intermediate devices have at least one different transmission task transmitted by the number of files transmitted by the intermediate devices, that is, at least two of the four available intermediate devices have a different transmission task transmitted (for example, the transmission tasks of b1 and b2 are different, b1's transmission task is f1, and b2's transmission task is f2). Among them, b3's transmission task is f1, and b4's transmission task is f2.
[0162] It should be noted that for the specific implementation of other contents, please refer to Figures 1-4 The relevant description in the embodiments will not be repeated here.
[0163] Figure 7 A schematic diagram of the structure of the file transmission device provided in the embodiment of the present application Figure 1 , the device can be integrated into the above-mentioned second device. Figure 7 As shown, the device includes:
[0164] A determination module 701 is configured to determine, in response to a file transfer instruction, at least two files to be transferred on a first device;
[0165] An acquisition module 702 is configured to acquire the number of at least two available intermediate devices and the number of at least two files to be transferred;
[0166] The acquisition module 702 is further configured to, if the number of files is greater than or equal to the number of devices, acquire at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transferred, different available intermediate devices have different at least one transmission task, or different available intermediate devices have the same at least one transmission task but a different transmission order of the at least one transmission task, and at least two available intermediate devices are intermediate devices that are communicatively connected to the first device and the second device, respectively;
[0167] The execution module 703 is configured to execute at least one transmission task in sequence through an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0168] In an optional implementation, the acquisition module 702 is specifically configured to:
[0169] The identifiers of at least two available intermediate devices and the identifiers of at least two files to be transferred are respectively cycled in sequence to obtain a device identifier sorting and a file identifier sorting;
[0170] Determine the ratio of the number of files to the number of devices;
[0171] If the ratio of the number of files to the number of devices is a fraction, then the device identification order and the file identification order are matched in sequence to obtain a first number of transmission tasks of the available intermediate devices, where the first number is the numerator of the target ratio, and the target ratio is the ratio of the number of files to the greatest common divisor of the number of files and the number of devices;
[0172] The first number of transmission tasks of different available intermediate devices is different, or the first number of transmission tasks of different available intermediate devices is the same but the transmission order of the first number of transmission tasks of different available intermediate devices is different.
[0173] In an optional implementation, the acquisition module 702 is specifically configured to:
[0174] If the ratio of the number of files to the number of devices is a positive integer, the device identification sort and the file identification sort are matched in sequence to obtain a second number of transmission tasks of the available intermediate devices;
[0175] The second number is the ratio of the number of files to the number of devices; the second number of transmission tasks for different available intermediate devices is different.
[0176] In an optional embodiment, the device further comprises:
[0177] The removal module 704 is configured to delete an uncompleted transmission task from at least one transmission task of an available intermediate device after the transmission of at least two files to be transmitted is completed.
[0178] In an optional implementation, the determining module 701 is further configured to:
[0179] In response to the file transfer instruction, determining an identifier of the intermediate device from a configuration file of the first device or the second device, the first device or the second device being a local device;
[0180] The intermediate devices corresponding to the identifications that have successfully established communication connections with the first device and the second device respectively are used as at least two available intermediate devices.
[0181] In an optional implementation, the file transfer instruction includes identification information of a specified directory on the first device, and the determination module 701 is specifically configured to:
[0182] In response to the file transfer instruction, obtaining a file in the specified directory on the first device according to identification information of the specified directory on the first device;
[0183] Obtain at least two files to be transferred based on the files in the specified directory on the first device;
[0184] and / or;
[0185] The file transfer instruction also includes: identification information of a designated directory on the second device; a storage module 705 is configured to store the at least two files to be transferred that have been transferred to the designated directory on the second device according to the identification information of the designated directory on the second device.
[0186] In an optional implementation, the first device is a local device and the second device is a remote device; or, the first device is a remote device and the second device is a local device.
[0187] In the file transfer device of this embodiment, by obtaining the device number of at least two available intermediate devices and the file number of at least two files to be transferred, when the file number is greater than or equal to the device number, at least one transfer task is obtained for each available intermediate device, and then at least one transfer task is executed in sequence by the available intermediate devices to transfer the file to be transferred corresponding to the at least one transfer task from the first device to the second device. At least one transfer task of different available intermediate devices is different, or at least one transfer task of different available intermediate devices is the same but the transmission order of at least one transfer task is different. In this way, different available intermediate devices transmit different files in parallel, which improves the transmission speed and reduces the total transmission time. Different available intermediate devices transmit the same file in parallel, which reduces the total transmission time. At the same time, through repeated transmission, the success rate of file transfer can be improved.
[0188] Figure 8 A schematic diagram of the structure of the file transmission device provided in the embodiment of the present application Figure 2 , the device can be integrated into the above-mentioned second device. Figure 8 As shown, the device includes:
[0189] A determination module 801 is configured to determine, in response to a file transfer instruction, at least two files to be transferred on a first device;
[0190] An acquisition module 820 is configured to acquire the number of at least two available intermediate devices and the number of at least two files to be transferred;
[0191] The acquisition module 802 is further configured to, if the number of files is less than the number of devices, acquire at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and at least one transmission task for at least the number of files available intermediate devices is different, or at least one transmission task is the same but the transmission order of at least one transmission task is different, or each available intermediate device transmits one transmission task for the number of files, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively.
[0192] The execution module 803 is configured to execute at least one transmission task in sequence through an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0193] In an optional implementation, the acquisition module 802 is specifically configured to:
[0194] The identifiers of at least two available intermediate devices and at least two files to be transferred are respectively cycled in sequence to obtain a device identifier sorting and a file identifier sorting;
[0195] Determine the ratio between the number of devices and the number of files;
[0196] If the ratio of the number of devices to the number of files is a fraction, then the device identification sorting and the file identification sorting are matched in sequence to obtain the third number of transmission tasks of the available intermediate devices;
[0197] The third number is the ratio of the number of files to the target common divisor, and the target common divisor is the greatest common divisor of the number of devices and the number of files; there are at least a third number of different transmission tasks of the number of files and available intermediate devices, or, the third number of transmission tasks are the same but the transmission order of the third number of transmission tasks is different.
[0198] In an optional implementation, the acquisition module 702 is specifically configured to:
[0199] If the ratio of the number of devices to the number of files is a positive integer, the device identification order and the file identification order are matched in sequence to obtain a transmission task for the available intermediate device, and each available intermediate device has a transmission task for each transmission task of the number of files to be transmitted;
[0200] Among them, at least two of the available intermediate devices have at least one transmission task that the number of files transmitted by the intermediate devices is different.
[0201] In the file transfer apparatus of this embodiment, at least one of the available intermediate devices has at least one different transmission task, or at least one of the available intermediate devices has at least one identical transmission task but a different transmission order, or each available intermediate device transmits one of the available intermediate devices, and at least one of the available intermediate devices transmits different tasks. In this way, different available intermediate devices transmit different files in parallel, improving transmission speed and reducing total transmission time. Furthermore, different available intermediate devices transmit the same file in parallel, reducing total transmission time and, through repeated transmission, improving the success rate of file transfers.
[0202] Figure 9 This is a structural diagram of an electronic device provided in an embodiment of the present application, which can be implemented by the above-mentioned second device. Figure 9 As shown, the device includes: a processor 901, a memory 902 and a bus 903. The memory 902 stores machine-readable instructions executable by the processor 901. When the electronic device is running, the processor 901 communicates with the memory 902 via the bus 903. The processor 901 executes the machine-readable instructions to perform the following steps:
[0203] In response to the file transfer instruction, determining at least two files to be transferred on the first device;
[0204] Obtain the device counts of at least two available intermediate devices and the file counts of at least two files to be transferred;
[0205] If the number of files is greater than or equal to the number of devices, obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, different available intermediate devices have at least one different transmission task, or different available intermediate devices have at least one same transmission task but a different transmission order of at least one transmission task, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively;
[0206] At least one transmission task is executed in sequence by an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0207] In an optional embodiment, obtaining at least one transmission task of each available intermediate device includes:
[0208] The identifiers of at least two available intermediate devices and the identifiers of at least two files to be transferred are respectively cycled in sequence to obtain a device identifier sorting and a file identifier sorting;
[0209] Determine the ratio of the number of files to the number of devices;
[0210] If the ratio of the number of files to the number of devices is a fraction, then the device identification order and the file identification order are matched in sequence to obtain a first number of transmission tasks of the available intermediate devices, where the first number is the numerator of the target ratio, and the target ratio is the ratio of the number of files to the greatest common divisor of the number of files and the number of devices;
[0211] The first number of transmission tasks of different available intermediate devices is different, or the first number of transmission tasks of different available intermediate devices is the same but the transmission order of the first number of transmission tasks of different available intermediate devices is different.
[0212] In an optional embodiment, obtaining at least one transmission task from each available intermediate device further includes:
[0213] If the ratio of the number of files to the number of devices is a positive integer, the device identification sort and the file identification sort are matched in sequence to obtain a second number of transmission tasks of the available intermediate devices;
[0214] The second number is the ratio of the number of files to the number of devices; the second number of transmission tasks for different available intermediate devices is different.
[0215] In an optional embodiment, the method further comprises:
[0216] After the transmission of at least two files to be transmitted is completed, the uncompleted transmission task of at least one transmission task of the available intermediate device is deleted.
[0217] In an optional embodiment, before obtaining the number of devices of the at least two available intermediate devices and the number of files of the at least two files to be transferred, the method further includes:
[0218] In response to the file transfer instruction, determining an identifier of the intermediate device from a configuration file of the first device or the second device, the first device or the second device being a local device;
[0219] The intermediate devices corresponding to the identifications that have successfully established communication connections with the first device and the second device respectively are used as at least two available intermediate devices.
[0220] In an optional embodiment, the file transfer instruction includes: identification information of a specified directory on the first device, and in response to the file transfer instruction, determining at least two files to be transferred on the first device includes:
[0221] In response to the file transfer instruction, obtaining a file in the specified directory on the first device according to identification information of the specified directory on the first device;
[0222] Obtain at least two files to be transferred based on the files in the specified directory on the first device;
[0223] and / or;
[0224] The file transfer instruction also includes: identification information of a specified directory on the second device, and the method further includes:
[0225] According to the identification information of the designated directory on the second device, the at least two files to be transferred that have been transferred are stored in the designated directory on the second device.
[0226] In an optional implementation, the first device is a local device and the second device is a remote device; or, the first device is a remote device and the second device is a local device.
[0227] Or to perform the following steps:
[0228] In response to the file transfer instruction, determining at least two files to be transferred on the first device;
[0229] Obtain the device counts of at least two available intermediate devices and the file counts of at least two files to be transferred;
[0230] If the number of files is less than the number of devices, then obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and there is at least one different transmission task for at least the number of files and available intermediate devices, or at least one transmission task is the same but the transmission order of at least one transmission task is different, or each available intermediate device transmits one transmission task for the number of files and there are at least different transmission tasks for the number of files and available intermediate devices, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device respectively;
[0231] At least one transmission task is executed in sequence by an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0232] In an optional embodiment, obtaining at least one transmission task of each available intermediate device includes:
[0233] The identifiers of at least two available intermediate devices and at least two files to be transferred are respectively cycled in sequence to obtain a device identifier sorting and a file identifier sorting;
[0234] Determine the ratio between the number of devices and the number of files;
[0235] If the ratio of the number of devices to the number of files is a fraction, then the device identification sorting and the file identification sorting are matched in sequence to obtain the third number of transmission tasks of the available intermediate devices;
[0236] The third number is the ratio of the number of files to the target common divisor, and the target common divisor is the greatest common divisor of the number of devices and the number of files; there are at least a third number of different transmission tasks of the number of files and available intermediate devices, or, the third number of transmission tasks are the same but the transmission order of the third number of transmission tasks is different.
[0237] In an optional embodiment, obtaining at least one transmission task from each available intermediate device further includes:
[0238] If the ratio of the number of devices to the number of files is a positive integer, the device identification order and the file identification order are matched in sequence to obtain a transmission task for the available intermediate device, and each available intermediate device has a transmission task for each transmission task of the number of files to be transmitted;
[0239] Among them, at least two of the available intermediate devices have at least one transmission task that the number of files transmitted by the intermediate devices is different.
[0240] An embodiment of the present application further provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the processor performs the following steps:
[0241] In response to the file transfer instruction, determining at least two files to be transferred on the first device;
[0242] Obtain the device counts of at least two available intermediate devices and the file counts of at least two files to be transferred;
[0243] If the number of files is greater than or equal to the number of devices, obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, different available intermediate devices have at least one different transmission task, or different available intermediate devices have at least one same transmission task but a different transmission order of at least one transmission task, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively;
[0244] At least one transmission task is executed in sequence by an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0245] In an optional embodiment, obtaining at least one transmission task of each available intermediate device includes:
[0246] The identifiers of at least two available intermediate devices and the identifiers of at least two files to be transferred are respectively cycled in sequence to obtain a device identifier sorting and a file identifier sorting;
[0247] Determine the ratio of the number of files to the number of devices;
[0248] If the ratio of the number of files to the number of devices is a fraction, then the device identification order and the file identification order are matched in sequence to obtain a first number of transmission tasks of the available intermediate devices, where the first number is the numerator of the target ratio, and the target ratio is the ratio of the number of files to the greatest common divisor of the number of files and the number of devices;
[0249] The first number of transmission tasks of different available intermediate devices is different, or the first number of transmission tasks of different available intermediate devices is the same but the transmission order of the first number of transmission tasks of different available intermediate devices is different.
[0250] In an optional embodiment, obtaining at least one transmission task from each available intermediate device further includes:
[0251] If the ratio of the number of files to the number of devices is a positive integer, the device identification sort and the file identification sort are matched in sequence to obtain a second number of transmission tasks of the available intermediate devices;
[0252] The second number is the ratio of the number of files to the number of devices; the second number of transmission tasks for different available intermediate devices is different.
[0253] In an optional embodiment, the method further comprises:
[0254] After the transmission of at least two files to be transmitted is completed, the uncompleted transmission task of at least one transmission task of the available intermediate device is deleted.
[0255] In an optional embodiment, before obtaining the number of devices of the at least two available intermediate devices and the number of files of the at least two files to be transferred, the method further includes:
[0256] In response to the file transfer instruction, determining an identifier of the intermediate device from a configuration file of the first device or the second device, the first device or the second device being a local device;
[0257] The intermediate devices corresponding to the identifications that have successfully established communication connections with the first device and the second device respectively are used as at least two available intermediate devices.
[0258] In an optional embodiment, the file transfer instruction includes: identification information of a specified directory on the first device, and in response to the file transfer instruction, determining at least two files to be transferred on the first device includes:
[0259] In response to the file transfer instruction, obtaining a file in the specified directory on the first device according to identification information of the specified directory on the first device;
[0260] Obtain at least two files to be transferred based on the files in the specified directory on the first device;
[0261] and / or;
[0262] The file transfer instruction also includes: identification information of a specified directory on the second device, and the method further includes:
[0263] According to the identification information of the designated directory on the second device, the at least two files to be transferred that have been transferred are stored in the designated directory on the second device.
[0264] In an optional implementation, the first device is a local device and the second device is a remote device; or, the first device is a remote device and the second device is a local device.
[0265] Or to perform the following steps:
[0266] In response to the file transfer instruction, determining at least two files to be transferred on the first device;
[0267] Obtain the device counts of at least two available intermediate devices and the file counts of at least two files to be transferred;
[0268] If the number of files is less than the number of devices, then obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and there is at least one different transmission task for at least the number of files and available intermediate devices, or at least one transmission task is the same but the transmission order of at least one transmission task is different, or each available intermediate device transmits one transmission task for the number of files and there are at least different transmission tasks for the number of files and available intermediate devices, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device respectively;
[0269] At least one transmission task is executed in sequence by an available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of at least two to-be-transmitted files is completed.
[0270] In an optional embodiment, obtaining at least one transmission task of each available intermediate device includes:
[0271] The identifiers of at least two available intermediate devices and at least two files to be transferred are respectively cycled in sequence to obtain a device identifier sorting and a file identifier sorting;
[0272] Determine the ratio between the number of devices and the number of files;
[0273] If the ratio of the number of devices to the number of files is a fraction, then the device identification sorting and the file identification sorting are matched in sequence to obtain the third number of transmission tasks of the available intermediate devices;
[0274] The third number is the ratio of the number of files to the target common divisor, and the target common divisor is the greatest common divisor of the number of devices and the number of files; there are at least a third number of different transmission tasks of the number of files and available intermediate devices, or, the third number of transmission tasks are the same but the transmission order of the third number of transmission tasks is different.
[0275] In an optional embodiment, obtaining at least one transmission task from each available intermediate device further includes:
[0276] If the ratio of the number of devices to the number of files is a positive integer, the device identification order and the file identification order are matched in sequence to obtain a transmission task for the available intermediate device, and each available intermediate device has a transmission task for each transmission task of the number of files to be transmitted;
[0277] Among them, at least two of the available intermediate devices have at least one transmission task that the number of files transmitted by the intermediate devices is different.
[0278] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment and will not be repeated here.
[0279] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0280] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0281] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0282] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0283] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0284] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present application, or make equivalent replacements for some of the technical features thereof. However, these modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A file transmission method, characterized in that: include: In response to the file transfer instruction, determining at least two files to be transferred on the first device; Obtaining the number of at least two available intermediate devices and the number of the at least two files to be transferred; If the number of files is greater than or equal to the number of devices, obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and different available intermediate devices have different at least one transmission task, or the different available intermediate devices have the same at least one transmission task but a different transmission order of the at least one transmission task, and the at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively; sequentially executing the at least one transmission task through the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed; The obtaining of at least one transmission task from each available intermediate device includes: Cycling the identifiers of the at least two available intermediate devices and the identifiers of the at least two files to be transferred in sequence to obtain a device identifier sorting and a file identifier sorting; determining a ratio of the number of files to the number of devices; If the ratio of the number of files to the number of devices is a fraction, the device identification order and the file identification order are matched in sequence to obtain a first number of transmission tasks for the available intermediate devices, where the first number is a numerator of a target ratio, and the target ratio is a ratio of the number of files to the greatest common divisor of the number of files and the number of devices; The first number of transmission tasks of the different available intermediate devices is different, or the first number of transmission tasks of the different available intermediate devices is the same but the transmission order of the first number of transmission tasks of the different available intermediate devices is different.
2. The method according to claim 1, characterized in that The acquiring of at least one transmission task from each available intermediate device further comprises: If the ratio of the number of files to the number of devices is a positive integer, matching the device identification order and the file identification order in sequence to obtain a second number of transmission tasks for the available intermediate devices; The second number is a ratio of the number of files to the number of devices; and the second number of transmission tasks of different available intermediate devices is different.
3. The method according to claim 1, characterized in that The method further comprises: After the transmission of the at least two files to be transmitted is completed, the uncompleted transmission task in the at least one transmission task of the available intermediate device is deleted.
4. The method according to claim 1, wherein Before obtaining the number of at least two available intermediate devices and the number of at least two files to be transferred, the method further includes: In response to the file transfer instruction, determining an identifier of an intermediate device from a configuration file of the first device or the second device, the first device or the second device being a local device; Among the intermediate devices corresponding to the identifiers, the intermediate devices that have successfully established communication connections with the first device and the second device respectively are used as the at least two available intermediate devices.
5. The method according to claim 1, wherein The file transfer instruction includes: identification information of a specified directory on the first device, and the determining, in response to the file transfer instruction, at least two files to be transferred on the first device includes: In response to the file transfer instruction, obtaining files in the specified directory on the first device according to identification information of the specified directory on the first device; Obtaining the at least two files to be transferred based on the files in the specified directory on the first device; and / or; The file transfer instruction further includes: identification information of a specified directory on the second device, and the method further includes: According to the identification information of the designated directory on the second device, the at least two files to be transferred that have been transferred are stored in the designated directory on the second device.
6. The method according to claim 1, characterized in that The first device is a local device, and the second device is a remote device; or, the first device is a remote device, and the second device is a local device.
7. A file transmission method, characterized in that: include: In response to the file transfer instruction, determining at least two files to be transferred on the first device; Obtaining the number of at least two available intermediate devices and the number of the at least two files to be transferred; If the number of files is less than the number of devices, obtaining at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transmitted, and at least one transmission task for at least the number of files and the number of available intermediate devices is different, or the at least one transmission task is the same but the transmission order of the at least one transmission task is different, or each available intermediate device transmits one transmission task from the number of files, and at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively; sequentially executing the at least one transmission task through the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed; The obtaining of at least one transmission task from each available intermediate device includes: Cycling the identifiers of the at least two available intermediate devices and the at least two files to be transferred in sequence to obtain a device identifier sorting and a file identifier sorting; determining a ratio of the number of devices to the number of files; If the ratio of the number of devices to the number of files is a fraction, matching the device identification order and the file identification order in sequence to obtain a third number of transmission tasks for the available intermediate devices; The third number is the ratio of the number of files to the target common divisor, and the target common divisor is the greatest common divisor of the number of devices and the number of files; there are at least the third number of transmission tasks of the available intermediate devices of the number of files that are different, or, the third number of transmission tasks are the same but the transmission order of the third number of transmission tasks is different.
8. The method according to claim 7, characterized in that The acquiring of at least one transmission task from each available intermediate device further comprises: If the ratio of the number of devices to the number of files is a positive integer, the device identification order and the file identification order are matched in sequence to obtain a transmission task of the available intermediate device, and each available intermediate device transmits one transmission task out of the number of files; Among them, there is at least one different transmission task of the number of files transmitted by the intermediate devices among the at least two available intermediate devices.
9. A file transmission device, characterized in that: include: a determining module, configured to determine, in response to a file transfer instruction, at least two files to be transferred on the first device; An acquisition module, configured to acquire the number of at least two available intermediate devices and the number of the at least two files to be transferred; The acquisition module is further configured to, if the number of files is greater than or equal to the number of devices, acquire at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transferred, and different available intermediate devices have different at least one transmission task, or the different available intermediate devices have the same at least one transmission task but a different transmission order of the at least one transmission task, and the at least two available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively; an execution module, configured to sequentially execute the at least one transmission task through the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed; The acquisition module is specifically used to: Cycling the identifiers of the at least two available intermediate devices and the identifiers of the at least two files to be transferred in sequence to obtain a device identifier sorting and a file identifier sorting; determining a ratio of the number of files to the number of devices; If the ratio of the number of files to the number of devices is a fraction, the device identification order and the file identification order are matched in sequence to obtain a first number of transmission tasks for the available intermediate devices, where the first number is a numerator of a target ratio, and the target ratio is a ratio of the number of files to the greatest common divisor of the number of files and the number of devices; The first number of transmission tasks of the different available intermediate devices is different, or the first number of transmission tasks of the different available intermediate devices is the same but the transmission order of the first number of transmission tasks of the different available intermediate devices is different.
10. A file transmission device, characterized in that: include: a determining module, configured to determine, in response to a file transfer instruction, at least two files to be transferred on the first device; An acquisition module, configured to acquire the number of at least two available intermediate devices and the number of the at least two files to be transferred; The acquisition module is further configured to, if the number of files is less than the number of devices, acquire at least one transmission task for each available intermediate device, wherein each transmission task corresponds to a file to be transferred, and at least one transmission task for at least the number of files and the number of available intermediate devices is different, or the at least one transmission task is the same but the transmission order of the at least one transmission task is different, or each available intermediate device transmits one transmission task from the number of files, and at least two of the available intermediate devices are intermediate devices communicatively connected to the first device and the second device, respectively; an execution module, configured to sequentially execute the at least one transmission task through the available intermediate device to transmit the to-be-transmitted file corresponding to the at least one transmission task from the first device to the second device until the transmission of the at least two to-be-transmitted files is completed; The acquisition module is specifically used to: Cycling the identifiers of the at least two available intermediate devices and the at least two files to be transferred in sequence to obtain a device identifier sorting and a file identifier sorting; determining a ratio of the number of devices to the number of files; If the ratio of the number of devices to the number of files is a fraction, matching the device identification order and the file identification order in sequence to obtain a third number of transmission tasks for the available intermediate devices; The third number is the ratio of the number of files to the target common divisor, and the target common divisor is the greatest common divisor of the number of devices and the number of files; there are at least the third number of transmission tasks of the available intermediate devices of the number of files that are different, or, the third number of transmission tasks are the same but the transmission order of the third number of transmission tasks is different.
11. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the processor executes the machine-readable instructions to perform the file transfer method according to any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the file transmission method according to any one of claims 1 to 8 is executed.
Citation Information
Patent Citations
Method, system and apparatus for transmitting files of P2P network
CN101304381A