File uploading method and device, electronic equipment and readable storage medium

By splitting large files according to the local network uplink bandwidth value and uploading them in parallel, the problem of poor file upload efficiency and stability in the prior art is solved, and more efficient and stable file transfer is achieved.

CN119814760AActive Publication Date: 2025-04-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, file upload efficiency and stability are poor, especially when large files are uploaded, they are susceptible to network fluctuations and cause upload interruption, and uploading needs to be restarted.

Method used

The target segmentation information of the target file is determined based on the uplink bandwidth value of the local network, and the target file slices are divided into multiple file slices, and the slices are transmitted to the target server through parallel upload.

Benefits of technology

Improve the efficiency and stability of file upload, reduce upload interrupts caused by network fluctuations, and improve file upload performance in the current network environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814760A_ABST
    Figure CN119814760A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a file uploading method and device, electronic equipment and a readable storage medium, and relates to the technical field of data transmission, and the method comprises the steps: determining target segmentation information corresponding to a target file based on an uplink bandwidth value of a local network; wherein the target segmentation information comprises a target slice number or a target slice size; segmenting the target file based on the target segmentation information to obtain a plurality of first file slices; and uploading the first file slice to the target server in parallel through the local network. According to the technical scheme, the target file needing to be uploaded can be segmented according to the uplink bandwidth value to obtain the multiple first file slices, the first file slices are uploaded to the target server in parallel, uploading of the target file is achieved, and the efficiency and stability of uploading the target file in the current network environment can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data transmission, and in particular relates to a file uploading method, device, electronic equipment and readable storage medium. Background Art

[0002] With the continuous development of Internet technology, more and more users and organizations have begun to use cloud disks, storage clusters, storage servers and other network-based storage solutions to record data files.

[0003] In the related art, the user selects the data file to be uploaded on the local terminal, and then sends the data file to the target server providing 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, completing the upload of the data file.

[0004] However, due to local network limitations, larger target files may take a long time to upload to the target server, and the upload process is easily affected by factors such as network fluctuations, resulting in upload interruptions and the need to restart uploading the target file, resulting in poor efficiency and stability in uploading files in related technologies. Summary of the invention

[0005] The present invention provides a file uploading method, device, electronic device and readable storage medium to solve the technical problem that the efficiency and stability of uploading files in the related art are poor.

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

[0007] Determine 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;

[0008] Segmenting the target file based on the target segmentation information to obtain a plurality of first file slices;

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

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

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

[0012] The target segmentation information is determined according to the uplink bandwidth value and a target threshold.

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

[0014] Extracting a first file segment matching the target segmentation information from the target file, and generating a first hash check code of the target file based on the first file segment;

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

[0016] The first hash check code and the second hash check code are sent to the target server, so that the target server verifies the target file based on the first hash check code and verifies the first file slice based on the second hash check code.

[0017] Optionally, the method further comprises:

[0018] In response to the uploaded slice information corresponding to the uploaded file slice sent by the target server, determining the non-uploaded file segment from the target file based on the uploaded slice information;

[0019] Segment the non-uploaded file segment based on the target segmentation information to obtain a plurality of second file slices;

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

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

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

[0023] A first file segment matching the target segmentation information is extracted from the to-be-segmented file segments.

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

[0025] Segment the to-be-segmented file segment based on the target segmentation information to obtain a plurality of file segment slices;

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

[0027] Optionally, the generating second hash check codes respectively corresponding to the first file slices includes:

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

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

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

[0031] A segmentation information module, used to determine 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 target slice quantity or the target slice size;

[0032] A slicing module, configured to slice the target file based on the target segmentation information to obtain a plurality of first file slices;

[0033] An upload module is used to upload the first file slices in parallel to the target server through the local network.

[0034] Optionally, the segmentation information module includes:

[0035] An uplink bandwidth value submodule, configured to 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;

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

[0037] Optionally, the device further comprises:

[0038] A first hash check code module is used to extract a first file segment matching the target segmentation information from the target file, and generate a first hash check code of the target file based on the first file segment;

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

[0040] A 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 comprises:

[0042] a non-uploaded file segment module, configured to respond to uploaded segment information corresponding to the uploaded file segment sent by the target server, and determine the non-uploaded file segment from the target file based on the uploaded segment information;

[0043] A non-uploaded file segment slicing module, configured to slice the non-uploaded file segment based on the target segmentation information to obtain a plurality of second file slices;

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

[0045] Optionally, the first hash check code module includes:

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

[0047] The first file segment submodule is used to extract the first file segment matching the target segmentation information from the to-be-segmented file segments.

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

[0049] A file segment slicing unit, configured to segment the to-be-segmented file segment based on the target segmentation information to obtain a plurality of file segment slices;

[0050] The first file segment extraction unit is configured to extract the first file segment from the file segment slice based on a slice size of the file segment slice.

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

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

[0053] The verification code generation submodule is used to generate second hash verification codes corresponding to the first file slices respectively based on the verification code generation task.

[0054] In a third aspect, 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, wherein the processor implements the above-mentioned file uploading method when executing the program.

[0055] In a fourth aspect, the present invention provides a readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the above-mentioned file uploading method.

[0056] In an embodiment of the present invention, the following steps are included: determining target segmentation information corresponding to a target file based on an uplink bandwidth value of a local network; wherein the target segmentation information includes a target number of slices or a target slice size; segmenting the target file based on the target segmentation information to obtain a plurality of first file slices; and uploading the first file slices to a target server in parallel through a local network. The target file to be uploaded can be segmented 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 to achieve the upload of the target file, which helps to improve the efficiency and stability of uploading the target file in the current network environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 It is a flowchart of a method for uploading a file provided by an embodiment of the present invention;

[0059] Figure 2 is a flowchart of another method for uploading a file provided by an embodiment of the present invention;

[0060] Figure 3 This is one of the file uploading processes provided by the embodiment of the present invention;

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

[0062] Figure 5 is a structural diagram of a file transmission device provided by an embodiment of the present invention;

[0063] Figure 6 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0064] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0065] Reference Figure 1 , Figure 11 is a flowchart of a method for uploading a file provided by an embodiment of the present invention. Figure 1 As shown, the method may include:

[0066] Step 101, determining target segmentation information corresponding to a target file based on an uplink bandwidth value of a local network; wherein the target segmentation information includes a target slice quantity or a target slice size.

[0067] In the embodiment of the present invention, a user can upload a target file to a target server through a local network at a local terminal. The local terminal may include but is not limited to a mobile terminal, a computer, a local server, etc.; the local network refers to a network where the local terminal is connected to the Internet, or may refer to a network where the local network is connected to a 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 network disk server, a storage server, a computing server, etc., which are not specifically limited in the embodiment of the present invention.

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

[0069] In an embodiment of the present invention, the target segmentation information corresponding to the target file can be determined based on the uplink bandwidth value of the local network, wherein the target segmentation information can include the target slice number or the target slice size, and the uplink bandwidth value and the target slice number can be in direct proportion, that is, the larger the uplink bandwidth value, the larger the corresponding target slice number, otherwise vice versa; the uplink bandwidth value and the target slice size can be in inverse proportion, that is, the larger the uplink bandwidth value, the smaller the corresponding target slice size, otherwise vice versa. Generally speaking, the larger the uplink bandwidth value of the local network, the faster the speed of uploading the target file, the shorter the time required for uploading, and the smaller the possibility of problems in the uploading process, and a larger target slice number or a smaller target slice size can be set for the target file; and the smaller the uplink bandwidth value of the local network, the slower the speed of uploading the target file, the longer the time required for uploading, and the greater the possibility of problems in the uploading process, and a smaller target slice number 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, and the ratio between the uplink bandwidth value and the target threshold value may be calculated to obtain the target number of slices, or the ratio between the uplink bandwidth value and the target threshold value may be calculated to obtain the target slice size. For example, when the uplink bandwidth value is 30 mbps and the target threshold value is 1.6, the ratio between 30 and 1.6 may be rounded up or down to obtain the corresponding target number of slices of 18 or 19. The above target threshold value may be flexibly set by a technician according to actual business requirements, and is not specifically limited in the embodiments of the present invention.

[0071] In one embodiment, the target number of slices may be related not only to the uplink bandwidth value, but also to the file size of the target file. The file size of the target file may be compared with the uplink bandwidth value to determine the above target number of slices. For example, when the uplink bandwidth value is 30 mbps and the file size of the target file is 1024 MB, the byte unit of 1024 MB may be converted into a bit unit, i.e., 8192 MB, and then the ratio between 8192 and 30 may be rounded up or down, and the corresponding target number of slices may be 273 or 274.

[0072] It should be noted that, in an embodiment of the present invention, the target file may refer to a larger file to be uploaded, that is, a file to be uploaded whose size is greater than or equal to the target size, thereby avoiding slicing and uploading small files and affecting the upload efficiency of small files.

[0073] Optionally, since the speed of uploading files of the same size is different in network environments with different uplink bandwidths, the identification standards for small files in different uplink bandwidths may also be different. Therefore, in an embodiment of the present invention, the target size can be determined based on the uplink bandwidth value, and when 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 product of the uplink bandwidth value and the first preset ratio can be used as the target size. For example, when the uplink bandwidth value is 30 mbps and the first preset ratio is 10, the product of 30 and 10 can be calculated to obtain a target size of 300 mb. The first preset ratio can be flexibly set by technicians according to actual business needs, and the embodiment of the present invention does not specifically limit it.

[0075] Step 102: Segment the target file based on the target segmentation information to obtain a plurality of first file slices.

[0076] Since the smaller the uplink bandwidth value of the local network, the slower the speed of uploading the target file, the longer the time required for uploading, and the greater the possibility of problems occurring during the uploading process, a smaller target slice number or a larger target slice size can be set for the target file, so that the size of the first file slice obtained by slicing the target file according to the target slicing information is correlated with the uplink bandwidth value of the local network. For the same target file, the first file slice obtained by slicing according to a larger uplink bandwidth value can be larger, thereby ensuring that the first file slices obtained by slicing in different network environments can have approximately the same upload success rate, which helps to ensure the stability of file uploading while improving the efficiency of file uploading.

[0077] In the embodiment of the present invention, the target file can be segmented based on the target segmentation information to obtain multiple first file slices, that is, the target file is segmented into multiple first file slices, and 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 slices to the target server in parallel via the local network.

[0079] In an embodiment of the present invention, first file slices obtained by segmenting a target file can be uploaded in parallel from a local device to a target server via a local network. The parallel upload may include uploading all first file slices in parallel, or uploading a group of first file slices in parallel, and uploading different groups of first file slices in series, thereby realizing a combination of parallel and serial uploads. The number of first file slices included in the above group of first file slices can be set by the user or can be a default number, which is not specifically limited in the embodiment of the present application.

[0080] Optionally, before starting to upload, the upload order corresponding to each first file slice may also 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 number of target slices of the target file is 5, 5 first file slices are obtained after segmentation, 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, 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, first file slice 5.

[0082] In another implementation, the reverse order of the distribution order of the first file slices in the target file can be determined as the upload order of the first file slices. Continuing with the above example, the upload order of the above five first file slices can be: first file slice 5, first file slice 4, first file slice 3, first file slice 3, first file slice 1.

[0083] In another embodiment, an upload order can be randomly generated for each first file slice, and the upload order corresponding to each first file slice is inconsistent with its distribution order in the target file, thereby improving the security of uploading the target file. Using the above example, the upload order of the above five first file slices can be: first file slice 2, first file slice 1, first file slice 5, first file slice 3, first file slice 4.

[0084] It should be noted that the file upload method of the present invention can be implemented in an operating system, for example, a user can mount a network storage in the operating system, and the above-mentioned file upload process can be triggered when a target file is stored in the network storage; it can also be implemented in an application, for example, a user can run a cloud disk application, and the above-mentioned file upload process can be triggered when a target file is uploaded to a cloud storage control through the cloud disk application; it can also be implemented in a web page, for example, a user can access a cloud storage space or a network cloud disk through a web page, read a local target file through a web page, and upload it to the cloud storage space or the network cloud disk. The present invention can be applied to any application scenario where files need to be uploaded to a non-local storage space. Technicians can deploy the above-mentioned file upload method in environments such as operating systems, applications, and web pages according to actual business needs, and the embodiments of the present invention do not specifically limit this.

[0085] In summary, a file uploading method provided by an embodiment of the present invention includes: determining 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; segmenting the target file based on the target segmentation information to obtain multiple first file slices; and uploading the first file slices to the target server in parallel through the local network. The target file to be uploaded can be segmented according to the uplink bandwidth value to obtain multiple first file slices, and the first file slices can be uploaded to the target server in parallel to achieve the uploading of the target file, which helps to improve the efficiency and stability of uploading the target file in the current network environment.

[0086] Reference Figure 2 , Figure 2 FIG. 1 is a flowchart of another method for uploading a file provided by 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 through 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, data transmission capability of the local device, communication link status between the local device and the target server, data receiving capability of the target server, etc., in order to make the uplink bandwidth value more accurately reflect the communication speed between the local device and the target server, a standard file can be uploaded to the target server through the local network. After receiving the standard file, the target server can feedback the reception completion time of the standard file, calculate the upload duration of the standard file based on the reception completion time and the upload start time of the standard file, and calculate the uplink bandwidth value of the local network for the target server based on the upload duration and the file size of the standard file. Among them, the upload duration can also be calculated based on the upload start time and upload end time of the local device for the standard file; the above-mentioned standard file can be any file agreed with the target server, which may not contain actual content and only have a fixed file size.

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

[0090] Optionally, the uplink bandwidth value may be determined by the upload duration and file size of historical files, and the uplink bandwidth value may be continuously updated as users continue to upload. That is, after the target file uploaded this time is transmitted, the upload duration and file size of the target file may be obtained, and a new uplink bandwidth value may be recalculated based on the file size to update the old uplink bandwidth value.

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

[0092] In an embodiment of the present invention, the ratio between the uplink bandwidth value and the target threshold value can be calculated to obtain the target number of slices. For example, when the uplink bandwidth value is 30 mbps and the target threshold value is 1.6, the ratio between 30 and 1.6 can be rounded up or down to obtain the corresponding target number of slices of 18 or 19; the product between the uplink bandwidth value and the target threshold value can also be calculated to obtain the target slice size. The above target threshold value can be flexibly set by the technician according to the actual business needs, and the embodiment of the present invention does not specifically limit it.

[0093] Optionally, since the larger the target threshold, the larger the number of target slices, or the smaller the target slice size, the smaller the target threshold, the smaller the target segmentation information, or the larger the target slice size, and the file segmentation operation consumes computing resources, in order to avoid the situation where the efficiency of file segmentation on a device with poor performance is low, the target threshold can not only be a fixed value, but also can be calculated according to the performance index of the local device, so that a higher performance index can correspond to a smaller target threshold, and a lower performance index can correspond to a larger target threshold, so that low-performance devices can perform fewer segmentation operations and improve the efficiency of file segmentation. Among them, the above-mentioned performance index can include but is not limited to at least one of CPU frequency, number of CPU cores, memory frequency, memory capacity, etc., and the embodiment of the present invention does not make specific limitations.

[0094] Upload the standard file to the target server through the local network, determine the uplink bandwidth value based on the upload time and file size of the standard file, and determine the target segmentation information based on the uplink bandwidth value and the target threshold. This helps to calculate the target segmentation information that is more suitable for the local device according to the actual situation of the local device, and improve the accuracy of the target segmentation information.

[0095] Step 203: Segment the target file based on the target segmentation information to obtain a plurality of first file slices.

[0096] This step can be referred to as step 102, and will not be described in detail in this embodiment of the present invention.

[0097] Step 204: extract a first file segment that matches the target segmentation information from the target file, and generate a first hash check code for the target file based on the first file segment.

[0098] In order to improve the accuracy of uploading the target file, the first hash check code corresponding to the target file can be calculated so that after receiving the target file, the target server can determine whether the target file is correct according to the first hash check code. The first hash check code may include but is not limited to MD5 (Message Digest Algorithm 5) check code, SHA (Secure Hash Algorithm) check code, etc., which is not specifically limited in the embodiment of the present invention.

[0099] Specifically, since the target file may be large, it takes a lot of computing power to generate the first hash check code of the target file using the traditional method. In order to improve the generation speed of the first hash check code and reduce the verification computing power overhead of the target server, the first file fragments matching the above-mentioned 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 target slice size, and the fragment hash check codes corresponding to these first file fragments are calculated, and then these fragment hash check codes are spliced ​​to obtain the first hash check code of the target file.

[0100] The first file slice can be directly used as the first file segment. When the target segmentation information is the number of target segments, the size of the first file segment can be smaller than the size of the first file slice; for example, if the target file content is 1234567890, and the corresponding target segmentation information is 5, 2, 4, 6, 8, and 0 in the target file can be extracted as a first file segment respectively. Thus, the segment hash check code corresponding to the first file segment can be calculated faster.

[0101] It should be noted that the file contents included in different first file fragments may belong to completely different contents in the target file, and the file contents included in different first file fragments may also partially overlap in the target file, which is not specifically limited in the embodiment of the present invention.

[0102] Optionally, step 204 may include:

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

[0104] In an embodiment of the present invention, the first segment size of the file segment to be segmented of the target file can be determined according to the file size of the target file. Specifically, the file size of the target file can be multiplied by the first preset ratio to obtain the first segment size of the corresponding file segment to be segmented; illustratively, if the file size of the target file is 100MB and the first preset ratio is 0.9, the first segment size of the file segment to be segmented can be 100*0.9=90MB. A continuous content with a length of the first segment size can be directly intercepted from the target file as the file segment to be segmented of the target file.

[0105] It is also possible to determine the removal size for the target file according to the file size of the target file, determine the removal file fragment from the target file based on the removal size, and then remove the removal file fragment from the target file to obtain the remaining file fragments to be segmented. Among them, the removal file fragment can be located at the head, tail or middle of the target file, and the removal file fragment can include multiple; the removal size can be obtained based on the file size of the target file multiplied by the second preset multiplier; illustratively, if the file size of the target file is 100MB, the second preset multiplier is 0.05, and the proposed file fragment includes two fragments located at the head and tail of the target file respectively, then the second fragment size of each removal file fragment can be 100*0.05=5MB, then the 5MB content at the head of the target file can be removed, and the 5MB content at the tail of the target file can be removed, and the remaining file content is the file fragment to be segmented.

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

[0107] In the embodiment of the present invention, the first file segment matching the target segmentation information may be extracted from the to-be-segmented file segments based on the target segmentation information.

[0108] In the case where the target segmentation information includes the target number of slices, the file segment to be segmented can be directly segmented into the same number of slices as the target number to obtain the first file segment, and the number of the first file segment is the same as the target number of slices. In the case where the target segmentation information includes the target slice size, the segmented 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, there may be a first file segment with a size smaller than the target slice size in the segmentation result.

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

[0110] Sub-step 20421, segmenting the to-be-segmented file segment based on the target segmentation information to obtain a plurality of file segment slices.

[0111] In the embodiment of the present invention, the file segments to be segmented can be segmented based on the target segmentation information to obtain file segment slices matching the target segmentation information, that is, the number of file segment slices is equal to the number of target slices in the target segmentation information, or the size of the file segment slices is equal to the size of the target slice in the target segmentation information.

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

[0113] In an embodiment of the present invention, the slice size of the file segment slice and the third preset magnification may be multiplied to obtain the third segment size, and a first file segment may be extracted from the corresponding file segment slice based on the third segment size. For example, if the size of the file segment slice is 10MB and the third preset magnification is 0.1, 1MB of content may be extracted from the file segment slice as the corresponding first file segment. The extraction position may include the head position, tail position, random position, etc. of the file segment slice, which is not specifically limited in the embodiment of the present invention.

[0114] It should be noted that the value ranges of the first preset magnification, the second preset magnification and the third device ratio are all (0, 1).

[0115] By segmenting the to-be-segmented file segments based on the target segmentation information to obtain a plurality of file segment slices, and extracting the first file segment from the file segment slices based on the slice sizes of the file segment slices, it helps to improve the accuracy of obtaining the first file segment.

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

[0117] In order to improve the accuracy of uploading the first file slice, a second hash check code corresponding to the first file slice may be calculated so that after receiving the first file slice, the target server may determine whether the first file slice is correct according to the second hash check code. The second hash check code may include but is not limited to an MD5 check code, a SHA check code, etc., which is not specifically limited in the embodiment of the present invention.

[0118] Optionally, step 205 may include:

[0119] Sub-step 2051, executing the verification code generation code written in Rust language in the WebAssembly environment to generate a verification code generation task.

[0120] In an embodiment of the present invention, in order to improve the generation efficiency of the second hash check code corresponding to the first file slice, a technician may write a check code generation code in advance in Rust language, and when the second hash check code needs to be generated, execute the above check code generation code in the WebAssembly environment to generate a check code generation task. Among them, WebAssembly (Wasm) is a binary instruction format designed for high-performance applications, which allows code to run in a web browser and can provide faster execution speed than traditional JavaScript. Rust is a system programming language with the characteristics of high security, high speed and good concurrency. It helps to improve the running efficiency of the check code generation task while reducing the error rate of the check code calculation, and provides a highly reliable and efficient check code calculation method.

[0121] The above verification code generation task can exist in the WebAssembly environment in the form of a process, a program, a workflow, etc., and the embodiment of the present invention does not specifically limit it.

[0122] Sub-step 2052: Generate second hash check codes corresponding to the first file slices respectively 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 programs in a Web environment to generate corresponding processes, which can provide higher computing performance and stronger security. It should be noted that due to the high concurrency of WebAssembly, the checksum generation task can use parallel processing to generate the second hash checksum corresponding to multiple first file slices at one time, thereby further improving the generation efficiency of the second hash checksum.

[0124] Step 206: Send the first hash check code and the second hash check code to the target server, so that the target server verifies the target file based on the first hash check code and verifies the first file slice based on the second hash check code.

[0125] In an embodiment of the present invention, a first hash check code corresponding to the target file and a second hash check code corresponding to the first file slice may be sent to the target server before, during, or after sending the first file slice to the target server, so that the target server verifies the target file based on the first hash check code and verifies the first file slice based on the second hash check code. It should be noted that the first hash check code and the second hash check code may be transmitted to the target server using encrypted communication technology.

[0126] The target server can use the same method as that of generating the above-mentioned second hash check code to calculate the check code for the received first file slice, obtain the third hash check code corresponding to the first file slice, and then compare the second hash check code and the third hash check code to obtain the verification result of the first file slice. If the verification results of all first file slices are passed, the first file slice can be used to restore the target file, and then the same method as that of generating the above-mentioned first hash check code is used to calculate the check code for the restored target file, obtain the fourth hash check code of the target file, and then compare the first hash check code and the fourth hash check code to obtain the verification result of the target file. The target server can feedback the upload result according to the verification result. The upload result may include successful file upload, failed file upload, etc. In the case of failed file upload, the upload result may also include failed fragment information to instruct the local device to re-upload the corresponding first file fragment.

[0127] By extracting a first file segment that matches the target segmentation information from the target file, generating a first hash check code for the target file based on the first file segment; generating second hash check codes corresponding to the first file slices respectively; and sending the first hash check code and the second hash check code to the target server, so that the target server verifies the target file based on the first hash check code and verifies the first file slice based on the second hash check code, the accuracy of uploading the target file can be improved to a certain extent, and the inconsistency between the target file stored on the target server and the target file uploaded locally can be avoided.

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

[0129] In an embodiment of the present invention, the target server may be first notified of the upload task for the target file. After receiving the upload task for the target file, the target server may first search the storage database based on the file identifier or the first hash check code of the target file. If the storage database cannot match an uploaded file identical to the target file, the "new file upload" function is triggered, and an instruction to completely upload the target file is sent to the local end. The local end executes step 210 and uploads the first file slice to the target server in parallel via the local network.

[0130] If an uploaded file identical to the target file can be matched in the storage database and the uploaded file is complete (completely uploaded), the "instant transfer" function can be triggered to directly copy the file to the upload location of the target file (for example, the user storage space or user folder of the user corresponding to the target file), and feedback is given to indicate successful upload of the target file; if an uploaded file identical to the target file can be matched in the storage database and the uploaded file is incomplete, the "breakpoint resume" function can be triggered to read the uploaded slice information corresponding to the uploaded file slice of the uploaded file, and send the uploaded slice information to this end, triggering the "breakpoint resume" function based on this end, and executing step 207.

[0131] Specifically, in response to the uploaded slice information corresponding to the uploaded file slice sent by the target server, the non-uploaded file segment can be determined from the target file based on the uploaded slice information. Specifically, the uploaded slice information can include the starting position and ending position information of the uploaded file slice in the target file, the slice information of the first file slice of the target file can be matched with the uploaded slice information, the non-uploaded file slice can be determined from the first file slice, and all the non-uploaded file slices can be merged to obtain the non-uploaded file segment.

[0132] If the slice information of the first file slice of the target file does not match the uploaded slice information, for example, the uploaded file corresponding to the target file was sliced ​​using different target slice information when uploading, then the uploaded file segment can be directly determined from the target file based on the starting position and ending position information of the uploaded file segment in the target file, and the content in the target file other than the uploaded file segment can be determined as the non-uploaded file segment.

[0133] Step 208: Segment the non-uploaded file segment based on the target segmentation information to obtain a plurality of second file slices.

[0134] After determining the non-uploaded file segments of the target file, the non-uploaded file segments may be segmented based on target segmentation information determined based on the uplink bandwidth value of the local network to obtain second file slices.

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

[0136] In the embodiment of the present invention, the second file slice can be uploaded to the target server through the local network to implement the "breakpoint resume" function for the target file, further improving the upload efficiency of the target file.

[0137] By responding to the uploaded slice information corresponding to the uploaded file slice sent by the target server, based on the uploaded slice information, determining the non-uploaded file segment from the target file; segmenting the non-uploaded file segment based on the target segmentation information to obtain the second file slice; uploading the second file slice to the target server through the local network. When the target server has already stored part of the file content of the target file, the efficiency of the user uploading the target file to the target server can be improved.

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

[0139] In an embodiment of the present invention, if the storage database cannot match an uploaded file that is identical to the target file, the "new file upload" function is triggered, and an instruction to completely upload the target file is sent to the local end, which executes this step and uploads the first file slice in parallel to the target server through the local network.

[0140] This step can refer to step 103, and will not be described in detail in this embodiment of the present invention.

[0141] Reference Figure 3 , Figure 3 FIG. 1 shows one of the file upload processes provided by an embodiment of the present invention, such as Figure 3 As shown, first, the broadband information of the current user can be obtained, and the target slice size can be determined based on the broadband information. The target file is cut according to the target slice size to obtain multiple first file slices. The front end calculates the hash check code of each first file slice, and adds the first file slice and the corresponding hash check code to the upload preparation group; then the hash check code of the target file is calculated; then the back end (target server) is communicated to send the hash check code of the target file to determine whether there is an uploaded file identical to the target file on the back end. If not, the upload preparation group is executed to upload the file; if so, it is further determined whether the uploaded file is complete. If complete, the back end directly copies the uploaded file and feedbacks that the upload is complete; if incomplete, the back end returns the uploaded slice information corresponding to the uploaded file slice, and the front end determines the unuploaded file segment according to the uploaded slice information, and segments the unuploaded file segment to obtain the second file slice, and then adjusts the upload preparation group to include only the second file slice, and executes the upload preparation group to upload the file.

[0142] Reference Figure 4 , Figure 4 FIG. 2 shows a second file upload process provided by an embodiment of the present invention. Figure 4As shown, after executing the upload preparation group to upload files, a maximum of three file slices can be uploaded at the same time each time, and it is determined whether each file slice is uploaded successfully. If failed, it is added to the upload failure group. The file slices in the upload failure group can be repeatedly executed at a preset frequency until the upload is successful; if successful, it is added to the upload success group, and the successfully uploaded file slices are moved out of the upload preparation group, and it is determined whether all file slices have been uploaded. If completed, a file merge request is sent to the back end, and the back end merges all file slices to obtain the target file, and notifies the front end of the upload completion after the merge is completed; if not completed, continue uploading, merge the upload failure group into the upload preparation group, and continuously loop the above process until the target file is uploaded successfully.

[0143] In summary, another file upload method provided by an embodiment of the present invention includes: determining 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; segmenting the target file based on the target segmentation information to obtain multiple first file slices; and uploading the first file slices to the target server in parallel through the local network. The target file to be uploaded can be segmented according to the uplink bandwidth value to obtain multiple first file slices, and the first file slices can be uploaded to the target server in parallel to achieve the upload of the target file, which helps to improve the efficiency and stability of uploading the target file in the current network environment.

[0144] Reference Figure 5 , Figure 5 is a structural diagram of a file transmission device provided by an embodiment of the present invention. The file transmission 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 target slice quantity or the target slice size;

[0146] A slicing module 52, configured to slice the target file based on the target segmentation information to obtain a plurality of first file slices;

[0147] The uploading module 53 is used to upload the first file slices to the target server in parallel through the local network.

[0148] Optionally, the segmentation information module includes:

[0149] An uplink bandwidth value submodule, configured to 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;

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

[0151] Optionally, the device further comprises:

[0152] A first hash check code module is used to extract a first file segment matching the target segmentation information from the target file, and generate a first hash check code of the target file based on the first file segment;

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

[0154] A 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 comprises:

[0156] a non-uploaded file segment module, configured to respond to uploaded segment information corresponding to the uploaded file segment sent by the target server, and determine the non-uploaded file segment from the target file based on the uploaded segment information;

[0157] A non-uploaded file segment slicing module, configured to slice the non-uploaded file segment based on the target segmentation information to obtain a plurality of second file slices;

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

[0159] Optionally, the first hash check code module includes:

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

[0161] The first file segment submodule is used to extract the first file segment matching the target segmentation information from the to-be-segmented file segments.

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

[0163] A file segment slicing unit, configured to segment the to-be-segmented file segment based on the target segmentation information to obtain a plurality of file segment slices;

[0164] The first file segment extraction unit is configured to extract the first file segment from the file segment slice based on a slice size of the file segment slice.

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

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

[0167] The verification code generation submodule is used to generate second hash verification codes corresponding to the first file slices respectively based on the verification code generation task.

[0168] In summary, the file transfer device provided in the embodiment of the present invention can divide 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 to realize the uploading of the target file, which helps 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, and the file upload method of the aforementioned embodiment is implemented when the processor executes the program.

[0170] The present invention also provides a readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the file uploading method of the aforementioned embodiment.

[0171] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

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

[0173] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the description of the above specific languages ​​is for disclosing the best mode of the present invention.

[0174] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0175] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.

[0176] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0177] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may 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 may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0178] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.

[0179] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned 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 in the protection scope of the present invention.

[0181] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A file uploading method, characterized in that: The method comprises: Determine 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; Segmenting the target file based on the target segmentation information to obtain a plurality of first file slices; The first file slices are uploaded to the target server in parallel via the local network.

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

3. The method according to claim 1, characterized in that After segmenting the target file based on the target segmentation information, the method further includes: Extracting a first file segment matching the target segmentation information from the target file, and generating a first hash check code of the target file based on the first file segment; Generate second hash check codes corresponding to the first file slices respectively; The first hash check code and the second hash check code are sent to the target server, so that the target server verifies the target file based on the first hash check code and verifies the first file slice based on the second hash check code.

4. The method according to claim 3, characterized in that The method further comprises: In response to the uploaded slice information corresponding to the uploaded file slice sent by the target server, determining the non-uploaded file segment from the target file based on the uploaded slice information; Segment the non-uploaded file segment based on the target segmentation information to obtain a plurality of second file slices; The second file slice is uploaded to the target server in parallel via the local network.

5. The method according to claim 3, characterized in that: The step of extracting a first file segment matching the target segmentation information from the target file includes: Based on the file size of the target file, determining the file segments to be segmented from the target file; A first file segment matching the target segmentation information is extracted from the to-be-segmented file segments.

6. The method according to claim 5, characterized in that The step of extracting a first file segment matching the target segmentation information from the file segments to be segmented includes: Segment the to-be-segmented file segment based on the target segmentation information to obtain a plurality of file segment slices; The first file segment is extracted from the file segment slice based on a slice size of the file segment slice.

7. The method according to claim 3, characterized in that The generating second hash check codes respectively corresponding to the first file slices includes: Execute the checksum generation code written in Rust language in the WebAssembly environment to generate the checksum generation task; Based on the check code generation task, second hash check codes corresponding to the first file slices are generated.

8. A file transmission device, characterized in that: The device comprises: A segmentation information module, used to determine 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 target slice quantity or the target slice size; A slicing module, configured to slice the target file based on the target segmentation information to obtain a plurality of first file slices; An upload module is used to upload the first file slices in parallel to the target server through the local network.

9. 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 implements the method according to any one of claims 1 to 7 when executing the program.

10. A readable storage medium, characterized in that: When the instructions in the readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods described in claims 1-7.

Citation Information

Patent Citations

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

    CN111935227A

  • File transmission method and system and computer readable storage medium

    CN112492033A

  • Webpage-based file transmission method and device and readable storage medium

    CN115914207A

  • File fragment uploading method and device, vehicle and storage medium

    CN116112484A

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

    US8407265B1