A file uploading method and device, electronic equipment and readable storage medium

By splitting files based on local network bandwidth values ​​and uploading them in parallel, and using hash checksums, the issues of file upload efficiency and stability are resolved, enabling efficient file transfer in different network environments.

CN119814760BActive Publication Date: 2025-11-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411773031.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-11-11
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

In existing technologies, file upload efficiency and stability are poor, especially under local network bandwidth limitations and network fluctuations, resulting in long upload times and easy interruptions for large target files.

Method used

The target file is divided into multiple file slices based on the uplink bandwidth value of the local network. These slices are then uploaded in parallel, and a hash checksum is used to ensure the accuracy and stability of the upload.

Benefits of technology

It improves the efficiency and stability of file uploads, reduces the impact of network fluctuations on the upload process, and ensures the success rate of target files in different network environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814760B_ABST
    Figure CN119814760B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a file uploading method and device, electronic equipment and readable storage medium, and relate to the technical field of data transmission, comprising: determining target splitting information corresponding to a target file based on an uplink bandwidth value of a local network; wherein the target splitting information comprises a target number of slices or a target slice size; splitting the target file based on the target splitting information to obtain a plurality of first file slices; and uploading the first file slices to a target server in parallel through the local network. The target file to be uploaded can be split according to the uplink bandwidth value to obtain a plurality of first file slices, and the first file slices can be uploaded to the target server in parallel, so that the uploading of the target file is realized, which helps to improve the efficiency and stability of uploading the target file under the current network environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data transmission technology, and in particular relates to a file upload method, apparatus, electronic device, and readable storage medium. Background Technology

[0002] With the continuous development of Internet technology, more and more users and organizations are starting to use network-based storage solutions such as cloud drives, storage clusters, and storage servers to record data files.

[0003] In related technologies, users select the data file to be uploaded on their local terminal, and then send the data file to the target server that provides the network storage solution through the local network of the local terminal. After receiving all the contents of the data file, the target server stores it, thus completing the upload of the data file.

[0004] However, due to the limitations of the local network, larger target files may take a long time to be uploaded to the target server, and the upload process is easily affected by factors such as network fluctuations, which may cause the upload to be interrupted and need to be restarted. This results in poor efficiency and stability of file upload in related technologies. Summary of the Invention

[0005] This invention provides a file upload method, apparatus, electronic device, and readable storage medium to solve the technical problem of poor efficiency and stability in file uploads in related technologies.

[0006] In a first aspect, the present invention provides a file upload method, the method comprising:

[0007] The target segmentation information corresponding to the target file is determined based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices;

[0008] The target file is segmented based on the target segmentation information to obtain multiple first file slices;

[0009] The first file slice is uploaded to the target server in parallel via the local network.

[0010] Optionally, determining the target segmentation information corresponding to the target file based on the uplink bandwidth value of the local network includes:

[0011] Upload a standard file to the target server via the local network, and determine the uplink bandwidth value based on the upload duration and file size of the standard file;

[0012] The target segmentation information is determined based on the uplink bandwidth value and the target threshold.

[0013] Optionally, after segmenting the target file based on the target segmentation information, the method further includes:

[0014] Extract a first file segment from the target file that matches the target segmentation information, and generate a first hash checksum for the target file based on the first file segment;

[0015] Generate the second hash checksums corresponding to the first file slices respectively;

[0016] The first hash checksum and the second hash checksum are sent to the target server so that the target server can verify the target file based on the first hash checksum and verify the first file slice based on the second hash checksum.

[0017] Optionally, the method further includes:

[0018] In response to the uploaded slice information corresponding to the uploaded file slice sent by the target server, the unuploaded file fragment is determined from the target file based on the uploaded slice information;

[0019] Based on the target segmentation information, the unuploaded file fragments are segmented to obtain multiple second file slices;

[0020] The second file slice is uploaded in parallel to the target server via the local network.

[0021] Optionally, extracting the first file segment that matches the target segmentation information from the target file includes:

[0022] Based on the file size of the target file, determine the file segments to be segmented from the target file;

[0023] Extract the first file segment that matches the target segmentation information from the file segment to be segmented.

[0024] Optionally, extracting a first file segment that matches the target segmentation information from the file segment to be segmented includes:

[0025] Based on the target segmentation information, the file segment to be segmented is segmented to obtain multiple file segment slices;

[0026] The first file fragment is extracted from the file fragment slice based on the slice size of the file fragment slice.

[0027] Optionally, generating the second hash checksum corresponding to each of the first file slices includes:

[0028] Execute checksum generation code written in Rust within the WebAssembly environment to generate checksum generation tasks;

[0029] The second hash check codes corresponding to the first file slices are generated based on the check code generation task.

[0030] In a second aspect, the present invention provides a file transfer device, the device comprising:

[0031] The segmentation information module is used to determine the target segmentation information corresponding to the target file based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices;

[0032] The slicing module is used to slice the target file based on the target slicing information to obtain multiple first file slices;

[0033] The upload module is used to upload the first file slice to the target server in parallel via the local network.

[0034] Optionally, the segmentation information module includes:

[0035] The uplink bandwidth value submodule is used to upload a standard file to the target server through the local network, and determine the uplink bandwidth value based on the upload duration and file size of the standard file;

[0036] The target segmentation information submodule is used to determine the target segmentation information based on the uplink bandwidth value and the target threshold.

[0037] Optionally, the device further includes:

[0038] The first hash check code module is used to extract a first file segment from the target file that matches the target segmentation information, and generate a first hash check code for the target file based on the first file segment.

[0039] The second hash check code module is used to generate the second hash check codes corresponding to the first file slices respectively;

[0040] The verification code sending module is used to send the first hash verification code and the second hash verification code to the target server, so that the target server verifies the target file based on the first hash verification code and verifies the first file slice based on the second hash verification code.

[0041] Optionally, the device further includes:

[0042] The module for unuploaded file fragments is used to respond to the uploaded fragment information corresponding to the uploaded file fragment sent by the target server, and to determine the unuploaded file fragments from the target file based on the uploaded fragment information;

[0043] The unuploaded file fragment slicing module is used to slice the unuploaded file fragment based on the target slicing information to obtain multiple second file slices;

[0044] The second file slice upload module is used to upload the second file slice to the target server in parallel via the local network.

[0045] Optionally, the first hash checksum module includes:

[0046] The file segment to be segmented submodule is used to determine the file segments to be segmented from the target file based on the file size of the target file;

[0047] The first file fragment submodule is used to extract a first file fragment that matches the target segmentation information from the file fragment to be segmented.

[0048] Optionally, the first file fragment submodule includes:

[0049] The file fragment slicing unit is used to slice the file fragment to be sliced ​​based on the target slicing information to obtain multiple file fragment slices;

[0050] The first file fragment extraction unit is used to extract the first file fragment from the file fragment slice based on the slice size of the file fragment slice.

[0051] Optionally, the second hash check code module includes:

[0052] The checksum generation task submodule is used to execute checksum generation code written in Rust in the WebAssembly environment to generate checksum generation tasks.

[0053] The checksum generation submodule is used to generate second hash checksums corresponding to the first file slices based on the checksum generation task.

[0054] Thirdly, the present invention provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the above-described file upload method when executing the program.

[0055] Fourthly, the present invention provides a readable storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to perform the above-described file upload method.

[0056] In this embodiment of the invention, the method includes: determining target segmentation information corresponding to a target file based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices; segmenting the target file based on the target segmentation information to obtain multiple first file slices; and uploading the first file slices to a target server in parallel through the local network. This method enables the segmentation of the target file to be uploaded according to the uplink bandwidth value, obtaining multiple first file slices, and uploading the first file slices to the target server in parallel, thereby improving the efficiency and stability of uploading target files in the current network environment. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0058] Figure 1 This is a flowchart of the steps of a file upload method provided in an embodiment of the present invention;

[0059] Figure 2 This is a flowchart of another file upload method provided in an embodiment of the present invention;

[0060] Figure 3 This is one of the file upload processes provided in the embodiments of the present invention;

[0061] Figure 4 This is a second file upload process provided in an embodiment of the present invention;

[0062] Figure 5 This is a structural diagram of a file transfer device provided in an embodiment of the present invention;

[0063] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0064] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0065] Reference Figure 1 , Figure 1This is a flowchart illustrating the steps of a file upload method provided in an embodiment of the present invention. Figure 1 As shown, the method may include:

[0066] Step 101: Determine the target segmentation information corresponding to the target file based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices.

[0067] In this embodiment of the invention, a user can upload a target file to a target server from a local terminal via a local network. The local terminal may include, but is not limited to, a mobile terminal, a computer, a local server, etc.; the local network refers to the network connecting the local terminal to the Internet, or it may refer to the network connecting the local network to the local area network where the target server is located; the target file may include any form of file, such as a compressed file, a document file, a multimedia file, etc.; the target server may include, but is not limited to, a cloud storage server, a storage server, a computing server, etc., and this embodiment of the invention does not impose specific limitations.

[0068] Uplink bandwidth can represent the uplink speed of data transmission through the local network. In this embodiment of the invention, the maximum uplink speed of the Internet broadband used by the local terminal can be directly used as the uplink bandwidth value, for example, 30 Mbps.

[0069] In this embodiment of the invention, target segmentation information corresponding to a target file can be determined based on the uplink bandwidth value of the local network. The target segmentation information may include the number of target slices or the target slice size. The uplink bandwidth value and the number of target slices can be directly proportional, i.e., the larger the uplink bandwidth value, the larger the corresponding number of target slices, and vice versa. The uplink bandwidth value and the target slice size can also be inversely proportional, i.e., the larger the uplink bandwidth value, the smaller the corresponding target slice size, and vice versa. Generally speaking, a larger uplink bandwidth value of the local network results in a faster upload speed for the target file, a shorter upload time, and a lower probability of problems during the upload process. Therefore, a larger number of target slices or a smaller target slice size can be set for the target file. Conversely, a smaller uplink bandwidth value of the local network results in a slower upload speed, a longer upload time, and a higher probability of problems during the upload process. Therefore, a smaller number of target slices or a larger target slice size can be set for the target file.

[0070] Specifically, in one implementation, the target segmentation information may be related only to the uplink bandwidth value. The number of target slices can be obtained by calculating the ratio between the uplink bandwidth value and the target threshold, or the target slice size can be obtained by calculating the ratio between the uplink bandwidth value and the target threshold. For example, with an uplink bandwidth value of 30 Mbps and a target threshold of 1.6, the ratio between 30 and 1.6 can be rounded up or down to obtain a corresponding number of target slices of 18 or 19. The aforementioned target threshold can be flexibly set by technicians according to actual business needs, and this embodiment of the invention does not impose specific limitations.

[0071] In one implementation, the target slice count can be related not only to the uplink bandwidth value but also to the target file size. The target slice count can be determined by comparing the target file size with the uplink bandwidth value. For example, with an uplink bandwidth of 30 Mbps and a target file size of 1024 MB, the 1024 MB byte unit can be first converted to a bit unit (8192 MB), and then the ratio between 8192 and 30 can be rounded up or down to obtain a target slice count of 273 or 274.

[0072] It should be noted that, in this embodiment of the invention, the target file can refer to a larger file to be uploaded, that is, a file whose size is greater than or equal to the target size, thereby avoiding the impact on the upload efficiency of small files by uploading them in slices.

[0073] Optionally, since the upload speed of files of the same size varies in network environments with different uplink bandwidths, the criteria for identifying small files may also differ across uplink bandwidths. Therefore, in this embodiment of the invention, the target size can be determined based on the uplink bandwidth value, and if the file to be uploaded is greater than or equal to the target size, the file to be uploaded is determined to be the target file.

[0074] Specifically, the target size can be obtained by multiplying the uplink bandwidth value by a first preset multiplier. For example, with an uplink bandwidth value of 30 Mbps and a first preset multiplier of 10, the product of 30 and 10 can be calculated to obtain a target size of 300 Mbps. The aforementioned first preset multiplier can be flexibly set by technicians according to actual business needs, and this embodiment of the invention does not impose specific limitations.

[0075] Step 102: The target file is segmented based on the target segmentation information to obtain multiple first file slices.

[0076] Since a smaller uplink bandwidth value on the local network results in a slower upload speed and a longer upload time, the likelihood of problems during the upload process is greater. To mitigate this, a smaller number of target slices or a larger target slice size can be set for the target file. This ensures that the size of the first file slice obtained by segmenting the target file based on the target segmentation information is correlated with the uplink bandwidth value of the local network. For the same target file, a larger uplink bandwidth value results in a larger first file slice, thus guaranteeing that the first file slices obtained under different network environments have roughly the same upload success rate. This helps to improve file upload efficiency while ensuring file upload stability.

[0077] In this embodiment of the invention, the target file can be segmented based on target segmentation information to obtain multiple first file slices. That is, the target file is segmented into multiple first file slices, such that the number of first file slices is equal to the number of target slices, or the size of the first file slices is equal to the size of the target slices.

[0078] Step 103: Upload the first file slice to the target server in parallel via the local network.

[0079] In this embodiment of the invention, first file slices obtained by splitting a target file can be uploaded in parallel from a local device to a target server via a local network. This parallel uploading can include uploading all first file slices in parallel, or it can include uploading a group of first file slices in parallel, with different groups of first file slices uploaded serially, thus achieving a combined parallel and serial uploading method. The number of first file slices in a group of first file slices can be set by the user or can be a default number; this embodiment of the application does not impose specific limitations.

[0080] Optionally, before starting the upload, the upload order of each first file slice can be determined according to the distribution order of the first file slices in the target file.

[0081] In one implementation, the distribution order of the first file slices in the target file can be directly determined as the upload order of the first file slices. For example, if the target file has 5 target slices, and after splitting, 5 first file slices are obtained, and these 5 first file slices are distributed in the target file in the following order: first file slice 1, first file slice 2, first file slice 3, first file slice 4, and first file slice 5; then the upload order of the above 5 first file slices can be: first file slice 1, first file slice 2, first file slice 3, first file slice 4, and first file slice 5.

[0082] In another implementation, the upload order of the first file slices can be determined by reversing the distribution order of the first file slices in the target file. Following the example above, the upload order of the five first file slices could be: first file slice 5, first file slice 4, first file slice 3, first file slice 3, and first file slice 1.

[0083] In another implementation, the upload order for each first file slice can be randomly generated, ensuring that the upload order of each first file slice does not match its distribution order in the target file, thereby improving the security of uploading the target file. Following the above example, the upload order of the five first file slices could be: first file slice 2, first file slice 1, first file slice 5, first file slice 3, and first file slice 4.

[0084] It should be noted that the file upload method of this invention can be implemented in an operating system. For example, a user can mount a network storage device in the operating system, and the file upload process can be triggered when the target file is stored in the network storage device. It can also be implemented in an application. For example, a user can run a cloud drive application, and the file upload process can be triggered when the target file is uploaded to the cloud storage control through the cloud drive application. Furthermore, it can be implemented in a webpage. For example, a user can access cloud storage space or a network cloud drive through a webpage, read the local target file through the webpage, and upload it to the cloud storage space or network cloud drive. This invention can be applied to any application scenario that requires uploading files to non-local storage space. Technicians can deploy the above file upload method in operating systems, applications, webpages, and other environments according to actual business needs. This embodiment of the invention does not specifically limit this.

[0085] In summary, the file upload method provided by this invention includes: determining target segmentation information corresponding to a target file based on the uplink bandwidth value of a local network; wherein the target segmentation information includes the number of target slices or the size of target slices; segmenting the target file based on the target segmentation information to obtain multiple first file slices; and uploading the first file slices to a target server in parallel via the local network. This method enables the segmentation of the target file to be uploaded according to the uplink bandwidth value, obtaining multiple first file slices, and uploading the first file slices to the target server in parallel, thereby improving the efficiency and stability of uploading target files in the current network environment.

[0086] Reference Figure 2 , Figure 2 This is a flowchart illustrating the steps of another file upload method provided in an embodiment of the present invention. Figure 2 As shown, the method may include:

[0087] Step 201: Upload a standard file to the target server via the local network, and determine the uplink bandwidth value based on the upload duration and file size of the standard file.

[0088] Since the communication speed between the local device and the target server is affected by many factors, such as local broadband, the data transmission capacity of the local device, the communication link status between the local device and the target server, and the data reception capacity of the target server, a standard file can be uploaded to the target server via the local network to make the uplink bandwidth value more accurately reflect the communication speed between the local device and the target server. After receiving the standard file, the target server can report the reception completion time. Based on the reception completion time and the upload start time of the standard file, the upload duration of the standard file is calculated. Based on the upload duration and the file size of the standard file, the uplink bandwidth value of the local network for the target server is calculated. The upload duration can also be calculated based on the upload start time and upload end time of the standard file by the local device. The standard file can be any file agreed upon with the target server, and may not contain actual content, only having a fixed file size.

[0089] For example, if the standard file size is 10MB and the upload time to the target server via the local network is 10 seconds, then the uplink bandwidth value can be calculated as 10*8 / 10 = 8Mbps.

[0090] Optionally, the uplink bandwidth value can also be determined by the upload duration and file size of historical files, and continuously updated as users upload more files. In other words, after the target file for the current upload is completed, the upload duration and file size of the target file can be obtained, and a new uplink bandwidth value can be recalculated based on the file size to update the old uplink bandwidth value.

[0091] Step 202: Determine the target segmentation information based on the uplink bandwidth value and the target threshold.

[0092] In this embodiment of the invention, the ratio between the uplink bandwidth value and the target threshold can be calculated to obtain the target number of slices. For example, with an uplink bandwidth value of 30 Mbps and a target threshold of 1.6, the ratio between 30 and 1.6 can be rounded up or down to obtain a target slice number of 18 or 19. Alternatively, the product of the uplink bandwidth value and the target threshold can be calculated to obtain the target slice size. The target threshold can be flexibly set by technicians according to actual business needs, and this embodiment of the invention does not impose specific limitations.

[0093] Optionally, since a larger target threshold results in a larger number of target slices or a smaller target slice size, and a smaller target threshold results in smaller target segmentation information or a larger target slice size, and file segmentation operations consume computational resources, to avoid low file segmentation efficiency on devices with poor performance, the target threshold can not only be a fixed value, but can also be calculated based on the performance indicators of the local device. This allows higher performance indicators to correspond to smaller target thresholds, and lower performance indicators to correspond to larger target thresholds, thereby enabling low-performance devices to perform fewer segmentation operations and improving file segmentation efficiency. The aforementioned performance indicators may include, but are not limited to, at least one of CPU frequency, number of CPU cores, memory frequency, and memory capacity, and this embodiment of the invention does not impose specific limitations.

[0094] Upload a standard file to the target server via the local network. Based on the upload duration and file size of the standard file, determine the uplink bandwidth value. Then, determine the target segmentation information based on the uplink bandwidth value and the target threshold. This helps to calculate target segmentation information that is more suitable for the local device, improving the accuracy of the target segmentation information.

[0095] Step 203: The target file is segmented based on the target segmentation information to obtain multiple first file slices.

[0096] This step can be found in step 102, and will not be repeated in this embodiment of the invention.

[0097] Step 204: Extract a first file segment from the target file that matches the target segmentation information, and generate a first hash checksum of the target file based on the first file segment.

[0098] To improve the accuracy of uploaded target files, a first hash checksum corresponding to the target file can be calculated. This allows the target server to determine the correctness of the target file upon receiving it. The first hash checksum may include, but is not limited to, MD5 (Message Digest Algorithm 5) checksums, SHA (Secure Hash Algorithm) checksums, etc., and this embodiment of the invention does not impose specific limitations.

[0099] Specifically, since the target file may be large, generating the first hash checksum of the target file using traditional methods requires a lot of computing power. In order to improve the generation speed of the first hash checksum and reduce the computing power overhead of the target server, the first file fragments that match the above target segmentation information can be extracted from the target file. That is, the number of extracted first file fragments is equal to the number of target slices, or the size of the extracted first file fragments is equal to the size of the target slices. The fragment hash checksums corresponding to these first file fragments are calculated, and then these fragment hash checksums are concatenated to obtain the first hash checksum of the target file.

[0100] The first file slice can be directly used as the first file fragment mentioned above. When the target segmentation information is the number of target slices, the size of the first file fragment can be smaller than the size of the first file slice. For example, if the target file content is 1234567890, and its corresponding target segmentation information is 5, then 2, 4, 6, 8, and 0 from the target file can be extracted as a first file fragment respectively. This allows the fragment hash checksum corresponding to the first file fragment to be calculated more quickly.

[0101] It should be noted that the file content contained in different first file fragments may be completely different from the content in the target file, and the file content contained in different first file fragments may also partially overlap in the target file. This embodiment of the invention does not impose specific limitations.

[0102] Optionally, step 204 may include:

[0103] Sub-step 2041: Based on the file size of the target file, determine the file segments to be segmented from the target file.

[0104] In this embodiment of the invention, the first segment size of the file to be segmented can be determined based on the file size of the target file. Specifically, the file size of the target file can be multiplied by a first preset multiplier to obtain the first segment size of the corresponding file to be segmented; for example, if the file size of the target file is 100MB and the first preset multiplier is 0.9, then the first segment size of the file to be segmented can be 100 * 0.9 = 90MB. A continuous segment of content with a length equal to the aforementioned first segment size can be directly extracted from the target file as the file segment to be segmented from the target file.

[0105] Alternatively, a rejection size can be determined based on the target file's file size. Based on this rejection size, rejection segments can be identified from the target file, and then these rejection segments are removed to obtain the remaining file segments to be segmented. These rejection segments can be located at the beginning, end, or middle of the target file, and multiple rejection segments can be included. The rejection size can be obtained by multiplying the target file's file size by a second preset multiplier. For example, if the target file's file size is 100MB, the second preset multiplier is 0.05, and the proposed file segments include two segments located at the beginning and end of the target file, then the second segment size of each rejection segment can be 100 * 0.05 = 5MB. Therefore, the 5MB content at the beginning and the 5MB content at the end of the target file can be removed, leaving the remaining file content as the file segments to be segmented.

[0106] Sub-step 2042: Extract the first file segment that matches the target segmentation information from the file segment to be segmented.

[0107] In this embodiment of the invention, a first file segment that matches the target segmentation information can be extracted from the file segment to be segmented based on the target segmentation information.

[0108] If the target segmentation information includes the number of target slices, the file segment to be segmented can be directly segmented into the same number of parts as the target slices to obtain the first file segment, the number of which is the same as the number of target slices. If the target segmentation information includes the target slice size, the file segment can be segmented according to the target slice size to obtain the first file segment, and the size of the first file segment is the same as the target slice size. It should be noted that since the size of the file segment to be segmented may not be an integer multiple of the target slice size, the segmentation result may contain a first file segment with a size smaller than the target slice size.

[0109] Optionally, sub-step 2042 may include:

[0110] Sub-step 20421: Based on the target segmentation information, the file segment to be segmented is segmented to obtain multiple file segment slices.

[0111] In this embodiment of the invention, the file fragments to be segmented can be segmented based on the target segmentation information to obtain file fragment slices that match the target segmentation information. That is, the number of file fragment slices is equal to the number of target slices in the target segmentation information, or the size of the file fragment slices is equal to the size of the target slices in the target segmentation information.

[0112] Sub-step 20422: Extract the first file fragment from the file fragment slice based on the slice size of the file fragment slice.

[0113] In this embodiment of the invention, the slice size of the file fragment can be multiplied by a third preset multiplier to obtain a third fragment size. A first file fragment is then extracted from the corresponding file fragment slice based on this third fragment size. For example, if the file fragment slice size is 10MB and the third preset multiplier is 0.1, then 1MB of content can be extracted from that file fragment slice as the corresponding first file fragment. The extraction location can include the beginning, end, or random position of the file fragment slice; this embodiment of the invention does not impose specific limitations.

[0114] It should be noted that the values ​​of the first preset multiplier, the second preset multiplier, and the third equipment rate are all within the range of (0, 1).

[0115] By segmenting the file fragment to be segmented based on the target segmentation information, multiple file fragment slices are obtained. The first file fragment is extracted from the file fragment slices based on the slice size of the file fragment slices, which helps to improve the accuracy of obtaining the first file fragment.

[0116] Step 205: Generate the second hash check codes corresponding to the first file slices respectively.

[0117] To improve the accuracy of the first file slice upload, a second hash checksum corresponding to the first file slice can be calculated. This allows the target server to determine the correctness of the first file slice after receiving it, based on the second hash checksum. The second hash checksum may include, but is not limited to, MD5 checksums, SHA checksums, etc., and this embodiment of the invention does not impose specific limitations.

[0118] Optionally, step 205 may include:

[0119] Sub-step 2051: Execute the checksum generation code written in Rust in the WebAssembly environment to generate a checksum generation task.

[0120] In this embodiment of the invention, to improve the efficiency of generating the second hash checksum corresponding to the first file slice, technicians can pre-write checksum generation code in Rust. When the second hash checksum needs to be generated, this code is executed in the WebAssembly environment to generate the checksum generation task. WebAssembly (Wasm) is a binary instruction format designed for high-performance applications, allowing code to run in a web browser and providing faster execution speeds than traditional JavaScript. Rust is a systems programming language with high security, high speed, and good concurrency, which helps to improve the efficiency of the checksum generation task while reducing the checksum calculation error rate, providing a highly reliable and efficient checksum calculation method.

[0121] The aforementioned checksum generation task can exist in the WebAssembly environment through processes, programs, workflows, etc., and this embodiment of the invention does not impose specific limitations.

[0122] Sub-step 2052: Generate second hash check codes corresponding to the first file slices based on the check code generation task.

[0123] The combination of WebAssembly and Rust enables developers to write efficient and secure applications and run these applications in a web environment, generating corresponding processes that offer high computational performance and strong security. It should be noted that due to the high concurrency of WebAssembly, the checksum generation task can be processed in parallel to generate multiple second hash checksums corresponding to the first file slices simultaneously, thereby further improving the efficiency of second hash checksum generation.

[0124] Step 206: Send the first hash checksum and the second hash checksum to the target server, so that the target server can verify the target file based on the first hash checksum and verify the first file slice based on the second hash checksum.

[0125] In this embodiment of the invention, a first hash checksum corresponding to the target file and a second hash checksum corresponding to the first file slice can be sent to the target server before, during, or after sending the first file slice. This allows the target server to verify the target file based on the first hash checksum and verify the first file slice based on the second hash checksum. It should be noted that the first and second hash checksums can be transmitted to the target server using encrypted communication technology.

[0126] The target server can calculate the checksum of the received first file slice using the same method as generating the second hash checksum, obtaining the third hash checksum corresponding to the first file slice. Then, it compares the second and third hash checksums to obtain the verification result of the first file slice. If all verification results for the first file slices pass, the target file can be recovered using the first file slices. Then, using the same method as generating the first hash checksum, the target file's checksum is calculated to obtain the fourth hash checksum. Finally, the first and fourth hash checksums are compared to obtain the verification result of the target file. The target server can provide feedback on the upload result based on the verification result. The upload result can include whether the file upload was successful or failed. In the case of a failed upload, the upload result can also include information about the failed segment to instruct the local device to re-upload the corresponding first file slice.

[0127] By extracting a first file segment from the target file that matches the target segmentation information, generating a first hash checksum for the target file based on the first file segment, generating a second hash checksum corresponding to each of the first file segments, and sending the first and second hash checksums to the target server, the target server can verify the target file based on the first hash checksum and verify the first file segments based on the second hash checksum. This can improve the accuracy of the target file upload to a certain extent and avoid inconsistencies between the target file stored on the target server and the target file uploaded locally.

[0128] Step 207: In response to the uploaded slice information corresponding to the uploaded file slice sent by the target server, determine the unuploaded file fragments from the target file based on the uploaded slice information.

[0129] In this embodiment of the invention, the target server can be notified of the upload task for the target file. After receiving the upload task for the target file, the target server can first search the storage database according to the file identifier or the first hash check code of the target file. If no uploaded file with the same name as the target file is found in the storage database, the "new file upload" function is triggered, and the command to upload the target file completely is sent to the local end. The local end then executes step 210 to upload the first file slice to the target server in parallel through the local network.

[0130] If an uploaded file identical to the target file can be found in the storage database and the uploaded file is complete (fully uploaded), the "instant upload" function can be triggered. The file is directly copied to the upload location of the target file (e.g., the user's storage space or user folder corresponding to the target file), and a notification of successful upload is sent. If an uploaded file identical to the target file can be found in the storage database but the uploaded file is incomplete, the "resume upload" function can be triggered. The uploaded file slice information corresponding to the uploaded file slice of the uploaded file is read, and the uploaded slice information is sent to the local end, triggering the "resume upload" function on the local end and executing step 207.

[0131] Specifically, in response to the uploaded file slice information sent by the target server, the system can determine the unuploaded file segments from the target file based on the uploaded slice information. Specifically, the uploaded slice information can include the start and end positions of the uploaded file slices within the target file. The system can match the slice information of the first file slice of the target file with the uploaded slice information to determine the unuploaded file slices from the first file slice, and then merge all the unuploaded file slices to obtain the unuploaded file segments.

[0132] If the slice information of the first file slice of the target file cannot match the uploaded slice information, for example, if the uploaded file corresponding to the target file used different target segmentation information for slicing during upload, the uploaded file fragments can be directly determined from the target file based on the start and end positions of the uploaded file slices in the target file, and the content in the target file other than the uploaded file fragments can be determined as unuploaded file fragments.

[0133] Step 208: Based on the target segmentation information, the unuploaded file fragments are segmented to obtain multiple second file slices.

[0134] After identifying the unuploaded file segments of the target file, the unuploaded file segments can be segmented based on the target segmentation information determined by the uplink bandwidth value of the local network to obtain the second file slice.

[0135] Step 209: Upload the second file slice to the target server in parallel via the local network.

[0136] In this embodiment of the invention, a second file slice can be uploaded to the target server via the local network to achieve the "resumable upload" function for the target file, thereby further improving the upload efficiency of the target file.

[0137] By responding to the uploaded file slice information sent by the target server, the system identifies unuploaded file segments from the target file based on this information. These unuploaded file segments are then segmented based on the target file segmentation information to obtain a second file slice. This second file slice is then uploaded to the target server via the local network. This method improves the efficiency of uploading target files to the target server, even when the target server already stores a portion of the target file's content.

[0138] Step 210: Upload the first file slice to the target server in parallel via the local network.

[0139] In this embodiment of the invention, if no uploaded file matching the target file can be found in the storage database, the "new file upload" function is triggered, and an instruction to upload the target file completely is sent to the local end. The local end then executes this step, and the first file slice is uploaded to the target server in parallel via the local network.

[0140] This step can be found in step 103, and will not be repeated in this embodiment of the invention.

[0141] Reference Figure 3 , Figure 3 This illustrates one of the file upload processes provided by an embodiment of the present invention, such as... Figure 3 As shown, the process begins by obtaining the current user's broadband information. Based on this information, the target slice size is determined. The target file is then segmented according to the target slice size, resulting in multiple first file slices. The front-end calculates the hash checksum for each first file slice and adds the first file slice and its corresponding hash checksum to the upload preparation group. Next, the hash checksum of the target file is calculated. Then, the hash checksum of the target file is sent to the back-end (target server) to determine if a file identical to the target file already exists on the back-end. If not, the upload preparation group is executed to upload the file. If the file exists, the back-end further checks if the uploaded file is complete. If complete, the back-end directly copies the uploaded file and reports the upload as complete. If incomplete, the back-end returns the uploaded slice information corresponding to the uploaded file slice. The front-end uses this information to determine the unuploaded file segments and segments them to obtain second file slices. Finally, the upload preparation group is adjusted to contain only the second file slices, and the upload preparation group is executed to upload the file.

[0142] Reference Figure 4 , Figure 4 This illustrates a second file upload process provided by an embodiment of the present invention, such as... Figure 4As shown, after the upload preparation group starts uploading files, it can upload up to three file slices simultaneously at a time. It checks whether each file slice was uploaded successfully. If it fails, it is added to the upload failure group. The file slices in the upload failure group can be uploaded repeatedly at a preset frequency until they are uploaded successfully. If they are uploaded successfully, they are added to the upload success group, and the uploaded file slices are removed from the upload preparation group. It checks whether all file slices have been uploaded successfully. If they have, it sends a file merge request to the backend, which merges all file slices to obtain the target file and notifies the frontend that the upload is complete after the merge is completed. If the upload is not completed, it continues to upload, merging the upload failure group into the upload preparation group, and continuously repeats the above process until the target file is uploaded successfully.

[0143] In summary, another file upload method provided by this invention includes: determining target segmentation information corresponding to a target file based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices; segmenting the target file based on the target segmentation information to obtain multiple first file slices; and uploading the first file slices to a target server in parallel via the local network. This method enables the segmentation of the target file to be uploaded according to the uplink bandwidth value, obtaining multiple first file slices, and uploading the first file slices to the target server in parallel, thereby achieving the upload of the target file and helping to improve the efficiency and stability of uploading target files in the current network environment.

[0144] Reference Figure 5 , Figure 5 This is a structural diagram of a file transfer device provided in an embodiment of the present invention. The file transfer device 50 may include:

[0145] The segmentation information module 51 is used to determine the target segmentation information corresponding to the target file based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices;

[0146] Slicing module 52 is used to slice the target file based on the target slicing information to obtain multiple first file slices;

[0147] Upload module 53 is used to upload the first file slice to the target server in parallel via the local network.

[0148] Optionally, the segmentation information module includes:

[0149] The uplink bandwidth value submodule is used to upload a standard file to the target server through the local network, and determine the uplink bandwidth value based on the upload duration and file size of the standard file;

[0150] The target segmentation information submodule is used to determine the target segmentation information based on the uplink bandwidth value and the target threshold.

[0151] Optionally, the device further includes:

[0152] The first hash check code module is used to extract a first file segment from the target file that matches the target segmentation information, and generate a first hash check code for the target file based on the first file segment.

[0153] The second hash check code module is used to generate the second hash check codes corresponding to the first file slices respectively;

[0154] The verification code sending module is used to send the first hash verification code and the second hash verification code to the target server, so that the target server verifies the target file based on the first hash verification code and verifies the first file slice based on the second hash verification code.

[0155] Optionally, the device further includes:

[0156] The module for unuploaded file fragments is used to respond to the uploaded fragment information corresponding to the uploaded file fragment sent by the target server, and to determine the unuploaded file fragments from the target file based on the uploaded fragment information;

[0157] The unuploaded file fragment slicing module is used to slice the unuploaded file fragment based on the target slicing information to obtain multiple second file slices;

[0158] The second file slice upload module is used to upload the second file slice to the target server in parallel via the local network.

[0159] Optionally, the first hash checksum module includes:

[0160] The file segment to be segmented submodule is used to determine the file segments to be segmented from the target file based on the file size of the target file;

[0161] The first file fragment submodule is used to extract a first file fragment that matches the target segmentation information from the file fragment to be segmented.

[0162] Optionally, the first file fragment submodule includes:

[0163] The file fragment slicing unit is used to slice the file fragment to be sliced ​​based on the target slicing information to obtain multiple file fragment slices;

[0164] The first file fragment extraction unit is used to extract the first file fragment from the file fragment slice based on the slice size of the file fragment slice.

[0165] Optionally, the second hash check code module includes:

[0166] The checksum generation task submodule is used to execute checksum generation code written in Rust in the WebAssembly environment to generate checksum generation tasks.

[0167] The checksum generation submodule is used to generate second hash checksums corresponding to the first file slices based on the checksum generation task.

[0168] In summary, the file transfer device provided in this embodiment of the invention can segment the target file to be uploaded according to the uplink bandwidth value to obtain multiple first file slices, and upload the first file slices to the target server in parallel, thereby realizing the upload of the target file and helping to improve the efficiency and stability of uploading the target file in the current network environment.

[0169] Reference Figure 6 The present invention also provides a structural diagram of an electronic device, such as... Figure 6 As shown, it includes: a processor 1101, a memory 1102, and a computer program 11021 stored in the memory and executable on the processor. When the processor executes the program, it implements the file upload method of the aforementioned embodiment.

[0170] The present invention also provides a readable storage medium, wherein when the instructions in the storage medium are executed by the processor of an electronic device, the electronic device is able to perform the file upload method of the foregoing embodiments.

[0171] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0172] It should be noted that all information and data obtained in the embodiments of the present invention were obtained with the authorization of the information / data holder.

[0173] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of the invention.

[0174] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0175] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.

[0176] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0177] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention can also be implemented as a device or apparatus program for performing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0178] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.

[0179] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0180] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0181] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A file upload method, characterized in that, The method includes: The target segmentation information corresponding to the target file is determined based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices; The target file is segmented based on the target segmentation information to obtain multiple first file slices; The first file slice is uploaded to the target server in parallel via the local network; The target segmentation information is determined based on the uplink bandwidth value and the target threshold. The target threshold is inversely proportional to the device's performance indicators; After segmenting the target file based on the target segmentation information, the method further includes: Extract a first file segment from the target file that matches the target segmentation information, and generate a first hash checksum for the target file based on the first file segment; Generate the second hash checksums corresponding to the first file slices respectively; Send the first hash checksum and the second hash checksum to the target server so that the target server can verify the target file based on the first hash checksum and verify the first file slice based on the second hash checksum; Extracting the first file fragment from the target file that matches the target segmentation information includes: Based on the file size of the target file, determine the file segments to be segmented from the target file; Extract a first file segment that matches the target segmentation information from the file segment to be segmented; Extracting a first file segment from the file segment to be segmented that matches the target segmentation information includes: Based on the target segmentation information, the file segment to be segmented is segmented to obtain multiple file segment slices; The first file fragment is extracted from the file fragment slice based on the slice size of the file fragment slice.

2. The method according to claim 1, characterized in that, The determination of the target segmentation information corresponding to the target file based on the uplink bandwidth value of the local network includes: The uplink bandwidth value is determined based on the upload duration and file size of the standard file when a standard file is uploaded to the target server via the local network.

3. The method according to claim 1, characterized in that, The method further includes: In response to the uploaded slice information corresponding to the uploaded file slice sent by the target server, the unuploaded file fragment is determined from the target file based on the uploaded slice information; Based on the target segmentation information, the unuploaded file fragments are segmented to obtain multiple second file slices; The second file slice is uploaded in parallel to the target server via the local network.

4. The method according to claim 1, characterized in that, The generation of the second hash checksum corresponding to each of the first file slices includes: Execute checksum generation code written in Rust within the WebAssembly environment to generate checksum generation tasks; The second hash check codes corresponding to the first file slices are generated based on the check code generation task.

5. A file transfer device, characterized in that, The device includes: The segmentation information module is used to determine the target segmentation information corresponding to the target file based on the uplink bandwidth value of the local network; wherein, the target segmentation information includes the number of target slices or the size of the target slices; The slicing module is used to slice the target file based on the target slicing information to obtain multiple first file slices; The upload module is used to upload the first file slice to the target server in parallel via the local network; The target segmentation information is determined based on the uplink bandwidth value and the target threshold. The target threshold is inversely proportional to the device's performance indicators; After segmenting the target file based on the target segmentation information, the process further includes: Extract a first file segment from the target file that matches the target segmentation information, and generate a first hash checksum for the target file based on the first file segment; Generate the second hash checksums corresponding to the first file slices respectively; Send the first hash checksum and the second hash checksum to the target server so that the target server can verify the target file based on the first hash checksum and verify the first file slice based on the second hash checksum; Extracting the first file fragment from the target file that matches the target segmentation information includes: Based on the file size of the target file, determine the file segments to be segmented from the target file; Extract a first file segment that matches the target segmentation information from the file segment to be segmented; Extracting a first file segment from the file segment to be segmented that matches the target segmentation information includes: Based on the target segmentation information, the file segment to be segmented is segmented to obtain multiple file segment slices; The first file fragment is extracted from the file fragment slice based on the slice size of the file fragment slice.

6. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in any one of claims 1-4.

7. A readable storage medium, characterized in that, When the instructions in the readable storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method of any one of claims 1-4.

Citation Information

Patent Citations

  • Method for uploading file through browser, browser and electronic equipment

    CN111935227A

  • Hierarchical mapping of free blocks of cylinder groups of file systems built on slices of storage and linking of the free blocks

    US8407265B1