A file processing method and device, electronic equipment and storage medium
By dynamically adjusting the fragmentation value and network response speed, the problems of low file upload efficiency and poor stability are solved, achieving efficient and stable uploads in complex network environments.
Patent Information
- Application Number
- CN202411685168.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-11-22
AI Technical Summary
In existing technologies, file uploads are often inefficient and unstable due to the complex and ever-changing network environment, especially for large files, which are prone to interruption or failure.
By dynamically adjusting the fragmentation value and the fragmentation size according to the network response speed, the system adopts an initial fragmentation value and various changing relationships to adapt to changes in the network environment, including rapid growth, slow growth, and stable growth phases, and combines network environment data with adjustments made when switching network connections.
It improves the efficiency and stability of file uploads, adapts to complex and ever-changing network environments, and reduces the probability of upload interruptions and failures.
Smart Images

Figure CN119766798B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a file processing method and device, electronic equipment and storage medium. BACKGROUND
[0002] With the rapid development of Internet communication technology, the efficiency of data transmission has been continuously improved.
[0003] File uploading is a common data transmission scenario. For a small-sized file, one-time uploading can usually be completed quickly, while for a large-sized file, due to the limitation of network environment, one-time uploading may be interrupted or even failed.
[0004] In the related art, by uploading a file in fixed-size fragments, the risk of interruption or failure of uploading due to poor network conditions can be reduced. However, using fixed-size fragments for uploading still cannot adapt to complex and changeable network environments, affecting the efficiency and stability of file uploading. SUMMARY
[0005] In view of the above problems, the present application provides a file processing method and device, electronic equipment and storage medium to overcome the above problems or at least partially solve the above problems, comprising:
[0006] A file processing method, the method comprising:
[0007] In response to a request for uploading a file, an initial fragment value and a first change relationship are obtained; wherein the first change relationship represents that a target fragment value of the file increases at a preset rate as time increases;
[0008] According to the initial fragment value and the first change relationship, the file is uploaded in fragments;
[0009] During the process of uploading the file in fragments according to the initial fragment value and the first change relationship, a network response speed parameter value is obtained;
[0010] If the network response speed parameter value does not meet a preset threshold, a second change relationship is obtained; wherein the second change relationship represents that the target fragment value increases as time increases, and the change rate of the target fragment value decreases as time increases;
[0011] According to the second change relationship, the part of the file that has not been uploaded is uploaded in fragments;
[0012] The uploading result of the file is fed back.
[0013] Optionally, in the process of performing the chunk uploading on the incomplete uploading part of the file according to the second change relationship, the method further comprises:
[0014] obtaining a maximum chunk value;
[0015] if the target chunk value is greater than or equal to the maximum chunk value, performing the chunk uploading on the incomplete uploading part of the file according to the maximum chunk value.
[0016] Optionally, before the initial chunk value is obtained, the method further comprises:
[0017] obtaining first network environment data; wherein the first network environment data is network environment data corresponding to a first network connected by the client, and the network environment data comprises one or more of the following: network connection type, network bandwidth information, communication protocol information;
[0018] determining a network environment index value of the first network according to the first network environment data;
[0019] determining the initial chunk value and the maximum chunk value according to the network environment index value.
[0020] Optionally, the performing the chunk uploading on the file according to the initial chunk value and the first change relationship comprises:
[0021] performing the chunk uploading on the file according to the initial chunk value as the target chunk value, and increasing the target chunk value according to the first change relationship at a first preset time interval; wherein in adjacent time intervals, the target chunk value of a later time interval is a preset multiple of the target chunk value of an earlier time interval.
[0022] Optionally, the second change relationship is a logarithmic function relationship, and the logarithmic function relationship further comprises a preset constant, and the performing the chunk uploading on the incomplete uploading part of the file according to the second change relationship comprises:
[0023] determining the target chunk value according to the second change relationship, and performing the chunk uploading on the incomplete uploading part of the file according to the target chunk value;
[0024] increasing the target chunk value according to the second corresponding relationship at a second preset time interval; wherein in adjacent time intervals, the target chunk value of a later time interval and the target chunk value of an earlier time interval satisfy the logarithmic function relationship.
[0025] Optionally, the method further comprises:
[0026] In response to the operation of the client switching the network connection, second network environment data is acquired; wherein the second network environment data is network environment data corresponding to a second network to which the client is connected after switching the network connection;
[0027] According to the second network environment data, a second network environment index value of the second network is determined;
[0028] According to the second network environment index value, the initial shard value and the maximum shard value are re-determined.
[0029] Optionally, the method further comprises:
[0030] The upload data of each shard of the file is saved; wherein the upload data comprises one or more of the following: the target shard value corresponding to each shard, the serial number corresponding to each shard, the size information of the file, and the unique identifier corresponding to each shard;
[0031] It is determined whether there is a shard that fails to be uploaded;
[0032] If there is a shard that fails to be uploaded, the shard that fails to be uploaded is re-uploaded according to the upload data.
[0033] An apparatus for processing a file, the apparatus comprising:
[0034] An initial shard value and a first change relationship acquisition module is configured to acquire an initial shard value and a first change relationship in response to a request to upload a file; wherein the first change relationship represents that a target shard value of the file increases at a preset rate as time increases;
[0035] A first shard upload module is configured to upload the file in shards according to the initial shard value and the first change relationship;
[0036] A network response speed parameter value acquisition module is configured to acquire a network response speed parameter value during the process of uploading the file in shards according to the initial shard value and the first change relationship;
[0037] A second change relationship acquisition module is configured to acquire a second change relationship if the network response speed parameter value does not meet a preset threshold; wherein the second change relationship represents that the target shard value increases as time increases, and the rate of change of the target shard value decreases as time increases;
[0038] A second shard upload module is configured to upload the part of the file that has not been uploaded according to the second change relationship;
[0039] An upload result feedback module is configured to feed back the upload result of the file.
[0040] An electronic device comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program implementing the method of file processing as described above when executed by the processor.
[0041] A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program, the computer program implementing the method of file processing as described above when executed by a processor.
[0042] The embodiment of the present application has the following advantages: by responding to the request of uploading the file, the initial slice value and the first change relationship are obtained, wherein the first change relationship represents that the target slice value of the file increases by a preset multiple as the time increases, the file is uploaded in slices according to the initial slice value and the first change relationship, in the process of uploading the file in slices according to the initial slice value and the first change relationship, the network response speed parameter value is obtained, if the network response speed parameter value does not conform to the preset threshold, the second change relationship is obtained, wherein the second change relationship represents that the target slice value increases as the time increases, and the change rate of the target slice value decreases as the time increases, the part of the file that is not uploaded is uploaded in slices according to the second change relationship, and the uploading result of the file is fed back, which realizes dynamic adjustment of the target slice value, so that the file uploading in slices can adapt to the complex and changeable network environment, and not only improves the efficiency of file uploading, but also improves the stability of file uploading. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained according to these drawings without creative labor for those skilled in the art.
[0044] Figure 1 is a step flow chart of a file processing method provided by an embodiment of the present application;
[0045] Figure 2 is a target slice value change curve diagram provided by an embodiment of the present application;
[0046] Figure 3 is a schematic diagram of an uploaded data saving format of a slice provided by an embodiment of the present application;
[0047] Figure 4 is an implementation flow chart of another file processing method provided by an embodiment of the present application;
[0048] Figure 5is a structural block diagram of a file processing device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to make the above objectives, characteristics and advantages of the present application more obvious and easy to understand, the present application will be further described in detail below with reference to the drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0050] In the Internet application, the scene of uploading files is often encountered. If the uploaded file is not large, such as a text file, a picture file with low resolution, the operation can be completed quickly, and the interference is not large. However, if a high-resolution picture file, a video file or the like is uploaded, the waiting time during the uploading process is relatively long, and it is extremely easy to be affected by network fluctuations. If the uploading is disconnected in the middle process, it needs to be retransmitted. Especially in the real network environment, it may change from WIFI to 4G, 4G to 3G and the like. The uploading is easy to be interrupted, and it is difficult to succeed once for transmitting a large file. In addition, the server may be limited by resources, such as memory, central processing unit, network bandwidth and the like, so that it is difficult to transmit a large file.
[0051] The related technology adopts a fragmentation uploading manner to solve this problem. Specifically, a large file is divided into many small fragmented files, and data such as fragmented size, total number of fragments, fragment serial number and the like is recorded. Each time a fragment is uploaded, after the uploading is completed, a merging request is initiated to notify the server to merge the entire file. This way solves the problem of large file uploading, and to a certain extent, can solve the problem of insufficient server resource occupation. However, the network condition is relatively complex, the network bandwidth cannot be perceived by the client, and the fragment size is often fixed, so the uploading efficiency is relatively low, and the server resources are not better utilized.
[0052] Based on this, the present application proposes a method which can adapt to network conditions and dynamically adjust the size of the uploaded fragments, so as to improve the resource utilization and the uploading efficiency.
[0053] The embodiments of the present application will be described in detail below.
[0054] Reference Figure 1 Fig. 1 shows a step flowchart of a file processing method provided by an embodiment of the present application, which can specifically include the following steps:
[0055] In step 101, in response to a request for uploading a file, an initial shard value and a first change relationship are obtained; wherein the first change relationship represents that a target shard value of the file increases by a preset multiple as time increases.
[0056] In step 101, the target shard value is the shard value when the file is divided into shards. In order to adapt to complex and changeable network environment, the target shard value is dynamically adjusted. Therefore, an initial shard value is obtained as the target shard value when the file is divided into shards for the first time, and a preset first change relationship is obtained. The change relationship defines the change relationship of the adjustment of the target shard value according to a certain rule, and the first change relationship defines that the target shard value increases by a preset multiple as time increases. The initial shard value and the preset multiple can be set according to actual needs. For example, the initial shard value is set to 32mb, 64mb, etc. with reference to the original size of the file. The preset multiple can control the growth rate of the target shard value, for example, it can be set to 1.5 times, 2 times, etc.
[0057] As an example, the first correspondence relationship can be defined as S=k×S', wherein k is the preset multiple, S is the target shard value required for the current shard upload, and S' is the target shard value when the shard is performed last time.
[0058] In step 102, the file is uploaded by shards according to the initial shard value and the first change relationship.
[0059] In this embodiment, the stage of uploading the file by shards according to the initial shard value and the first change relationship can be regarded as a rapid growth stage. Because the target shard value is relatively small in this stage, it does not cause too much pressure on the network bandwidth, so the target shard value can be dynamically adjusted by a preset multiple. Moreover, in this stage, the shard increases from small to large, and the transmission speed also increases, so the speed of uploading the file can be accelerated.
[0060] In some embodiments of the present application, step 102 comprises:
[0061] The file is uploaded by shards with the initial shard value as the target shard value, and the target shard value is increased according to the first change relationship at a first preset time interval; wherein in adjacent time intervals, the target shard value of the next time interval is a preset multiple of the target shard value of the previous time interval.
[0062] As an example, in adjacent time intervals, let the target slice value of the previous time interval be S', the target slice value of the next time interval be S, the first correspondence be S = 2 x S', the first preset time interval be 2 seconds, the original size of the file be 1 GB (i.e. 1024 mb), and the initial slice value be defined as 32 mb, then the process of slicing and uploading the file is as follows:
[0063] When slicing the file for the first time, the file is sliced according to the initial slice value, 32 slices are obtained, each slice has a size (i.e. target slice value) of 32 mb, and all the slices are uploaded;
[0064] When the first preset time interval, i.e. 2 seconds, is reached, let there be 2 slices uploaded successfully, at this time the remaining part of the file is 1024 - 32 x 2 = 960 mb. According to the first change relationship, the target slice value is increased to 32 x 2 = 64 mb, the remaining 960 mb of the file is sliced again, 15 slices are obtained, each slice has a size of 64 mb, and all the slices are uploaded again. After another 2 seconds, the target slice value of the previous time interval and the first change relationship are adjusted again, and so on.
[0065] In actual applications, when the file is sliced and uploaded, the network environment can be continuously detected. If positive network feedback is obtained, i.e. the server responds within a certain time range, it can be considered that the current network environment is good and can bear greater bandwidth pressure, and the fast growth stage can be maintained.
[0066] Step 103, in the process of slicing and uploading the file according to the initial slice value and the first change relationship, a network response speed parameter value is obtained;
[0067] In step 103, the network response speed parameter value is a parameter value reflecting the current network response speed, such as network delay, packet loss rate, network transmission speed, etc.
[0068] Step 104, if the network response speed parameter value does not meet a preset threshold, a second change relationship is obtained; wherein the second change relationship indicates that the target slice value increases with time, and the change rate of the target slice value decreases with time;
[0069] In step 104, if the network response speed parameter value does not meet the preset threshold value, it is considered that the network begins to fluctuate at this time, and if the target slice value continues to increase according to the first change relationship of the fast growth stage, the speed will not only no longer have a positive effect, but in some network environments, the speed will decrease, thereby affecting the stability and speed of file uploading. At this time, a second change relationship is obtained to adjust the adjustment strategy of the change target slice value according to the second change relationship. The second change relationship indicates that the target slice value increases with the increase of time, and the change rate of the target slice value decreases with the increase of time. That is, at this time, the target slice value is still increasing, but the increasing speed is reduced.
[0070] In step 105, according to the second change relationship, the part of the file that has not been uploaded is uploaded in slices.
[0071] In step 105, after the fast growth stage, it is confirmed that the network response speed parameter value does not meet the preset threshold value, and the file is uploaded in slices by applying the second change relationship, so that the stage of uploading in slices enters the slow growth stage.
[0072] In some embodiments of the present application, the second change relationship is a logarithmic function relationship, and the logarithmic function relationship further includes a preset constant. Step 105 includes:
[0073] According to the second change relationship, the target slice value is determined, and the part of the file that has not been uploaded is uploaded in slices according to the target slice value.
[0074] According to the second corresponding relationship, the target slice value is increased at a second preset time interval; wherein in adjacent time intervals, the target slice value of the next time interval and the target slice value of the previous time interval meet the logarithmic function relationship.
[0075] As an example, it is assumed that the target slice value of the previous time interval is S', the target slice value of the next time interval is S, and the second corresponding relationship is S=C*ln(S ′ +1), where C is a preset constant.
[0076] When entering the slow growth stage, the target slice value of the last slice is obtained, for example, the target slice value of the last slice in the fast growth stage, and the second corresponding relationship is applied to determine the target slice value of the current slice.
[0077] Then, according to the second corresponding relationship, the target slice value is continuously increased at a second preset time interval, and the part of the file that has not been uploaded is uploaded in slices.
[0078] In the slow growth stage, the target slice value is in a growth trend with a normalized slope, and although it is still increasing, the increasing speed is relatively slow to adapt to the relatively volatile network environment, to ensure a certain file transmission rate and guarantee the stability of file transmission.
[0079] In practical applications, the second preset time interval and the first preset time interval can be the same or different, and can be set according to actual needs.
[0080] In some embodiments of the present application, in the process of performing slice uploading on the part of the file that has not been uploaded according to the second change relationship, the method further comprises:
[0081] obtaining a maximum slice value;
[0082] If the target slice value is greater than or equal to the maximum slice value, performing slice uploading on the part of the file that has not been uploaded according to the maximum slice value.
[0083] In this embodiment, when the target slice value is continuously increased according to the second change relationship, when the target slice value is increased to the maximum slice value, the uploading speed may decrease due to the continuous increase of the target slice value, because the increase of TCP retransmission caused by the increased network burden, and the larger the slice value, the higher the probability of file uploading failure. Therefore, at this time, the adjustment of the target slice value is stopped, and the part of the file that has not been uploaded is fixed to be slice uploaded with the maximum slice value, until all slices are uploaded. At this time, the growth of the target slice value is from the slow growth stage to the stable growth stage.
[0084] As an example, the maximum slice value is set to S max When the target slice value determined through the second corresponding relationship of the previous stage, for example, S ′ +1), exceeds S max , the part of the file that has not been uploaded is fixed to be slice uploaded with S max . The change curve of the target slice value through the fast growth stage A1, the slow growth stage A2, and the stable growth stage A3 can be as shown in Figure 2 .
[0085] In practical applications, the target slice value can also be dynamically adjusted according to real-time detection of the network. For example, the network environment is detected, and if in a good network, the slice size is increased; if in a poor network, the slice size is reduced. This dynamic adjustment mechanism can timely adjust the size of the uploaded slice according to the status of the network, thereby improving the success rate of file uploading.
[0086] In some embodiments of the present application, before the initial slice value is obtained, the method further comprises:
[0087] obtaining first network environment data; wherein the first network environment data is network environment data corresponding to a first network to which the client is connected, and the network environment data comprises one or more of the following: network connection type, network bandwidth information, communication protocol information;
[0088] determining a network environment index value of the first network according to the first network environment data;
[0089] determining the initial fragmentation value and the maximum fragmentation value according to the network environment index value.
[0090] In this embodiment, since the network state is different under different network environments, and the pressure borne by the network is also different, the network environment index value is determined through the network environment data, and then the initial fragmentation value and the maximum fragmentation value are determined according to the network environment index value, so that the file fragmentation upload can better adapt to the network environment and better utilize the network bandwidth.
[0091] As an example, when the network connection type of the first network to which the client is currently connected is a 5G network, and the network bandwidth is 1Gbps, etc., the first network environment index value is calculated according to these data through a preset algorithm. Then, the first network environment index value calculated reflects that the network environment of the first network is good, so a larger initial fragmentation value and a larger maximum fragmentation value can be set through a configuration mapping table or the like.
[0092] In actual application, different initial fragmentation values and maximum fragmentation values can also be set only through different network connection types. For example, the initial fragmentation value and the maximum fragmentation value corresponding to WIFI, 5G, 4G, etc. type of network connection are set respectively.
[0093] In some embodiments of the application, the method further comprises:
[0094] obtaining second network environment data in response to the operation of the client switching network connection; wherein the second network environment data is network environment data corresponding to a second network to which the client is connected after switching network connection;
[0095] determining a second network environment index value of the second network according to the second network environment data;
[0096] redetermining the initial fragmentation value and the maximum fragmentation value according to the second network environment index value.
[0097] In this embodiment, when the network connection of the client changes, for example, from WIFI connection to 4G network, 4G network to 5G network, etc., the original initial fragmentation value and the maximum fragmentation value have become inapplicable.
[0098] In a specific implementation, when the initial slice value and the maximum slice value are re-determined by the second network environment index value, the target slice value needs to be adjusted by a new initial slice value. For example, the target slice value is adjusted again according to the three stages of rapid growth, slow growth, and stable growth described above.
[0099] In this way, different network environments can be adapted to, for example, the bandwidth in a WIFI environment can be relatively large, a user switches to a 4G network at a certain moment, at which time the bandwidth of the 4G network can be smaller than that of the WIFI, the original target slice value can cause congestion in the 4G network environment, and the upload failure rate can increase, so the slice size is adjusted to the initial slice value in the 4G environment, and then the file is uploaded in slices again according to the three-stage structure, to ensure the upload success rate.
[0100] In actual applications, when a file is uploaded in slices and fails at a certain time, a retransmission mechanism can also be started. When retransmission is performed, the initial slice value is set to the initial slice value corresponding to the network environment currently connected by the client, and then the target slice value is adaptively adjusted according to the three-stage structure until all slices are uploaded. If the number of retransmissions exceeds a certain number of times, for example, 5 times, it can be determined that the entire file upload fails.
[0101] In some embodiments of the present application, the method further comprises:
[0102] Saving upload data of each slice of the file, wherein the upload data comprises one or more of the following: the target slice value corresponding to each slice, the serial number corresponding to each slice, the size information of the file, and the unique identifier corresponding to each slice;
[0103] Determining whether there is a slice that fails to be uploaded;
[0104] If there is a slice that fails to be uploaded, re-uploading the slice that fails to be uploaded according to the upload data.
[0105] In the present embodiment, the upload data of each slice can be saved during the process of uploading the file in slices, to realize breakpoint continuation.
[0106] In a specific implementation, a redis database can be used to save the upload data of each slice, such as the slice size (i.e., the target slice value when slicing), the slice serial number, the size information of the file, and the unique identifier (such as an MD5 (Message-Digest Algorithm 5, fifth edition message digest algorithm) value) corresponding to each slice.
[0107] Since the target shard value is dynamically adjusted, the target shard value at each time needs to be recorded to facilitate the system to learn that the shard has been successfully uploaded; the unique identifier can be used to check whether each shard is consistent to prevent the shard from being tampered during the uploading process.
[0108] The data structure for saving data in redis can be as shown in Figure 3
[0109] The key can be the unique identifier of the file, such as the MD5 value; the total size of the file total; the list of uploaded shards detail; the identifier of successful uploading success; the detail contains the name, size, index, etc. of each shard.
[0110] When each shard is uploaded, the shard data is recorded in the detail, and the success identifier is updated after all the shards are uploaded, for example, set to true of the Boolean type.
[0111] If there is a failed shard, the system will find the latest shard number of the file that has not been successfully uploaded, and only needs to upload the shard corresponding to the shard number.
[0112] In actual application, by saving the uploading data of the shard, the second transmission function can also be realized. For example, if the same file is repeatedly uploaded, the system will compare the MD5 value and the MD5 value recorded in redis, and if there is a successful uploading identifier, it is considered that the file has been successfully uploaded, and the second transmission file is realized.
[0113] In actual application, when all the shards are successfully uploaded, a merging request needs to be initiated to the server receiving the file. The server can merge the shards according to the shard number based on the saved uploading data of the shard. When merging the shards, the streaming merging method can be used, that is, each shard is converted into a data stream and then merged. The data in the data stream does not need to be loaded into the memory at one time, and the memory occupied by other merging methods is smaller, which can improve the efficiency of the shard merging.
[0114] Step 106, feedback the uploading result of the file.
[0115] In step 106, if all the shards of the file are successfully uploaded, a response of successful uploading can be fed back; otherwise, a response of failed uploading is fed back.
[0116] In some examples, for the convenience of understanding, the implementation process of the file uploading by shards can be as shown in Figure 4 The implementation process is as follows:
[0117] First, the initial slice value is taken as the target slice value, and the file is uploaded in slices, at this time, it is the fast growth (also known as fast start) stage, and the first change relationship is S = 2 x S'; then, when it is detected that the network response speed parameter value does not conform to the preset threshold value, the adjustment strategy of the target slice value is changed, and the second change relationship S = C x ln(S ′ +1) is applied for adjustment, at this time, it is the slow growth stage; when the target slice value is grown to the maximum slice value through the second change relationship, the adjustment of the target slice value is stopped, and the fixed S = S max The part of the file that is not uploaded is uploaded in slices.
[0118] When all the slices of the file are successfully uploaded, the server is notified to merge the slices; if the uploading fails, a retransmission mechanism is initiated, and the file is uploaded in slices according to the above process.
[0119] The embodiment of the application has the following advantages: by responding to the request of uploading the file, the initial slice value and the first change relationship are obtained, wherein the first change relationship represents that the target slice value of the file increases by a preset multiple as time increases, the file is uploaded in slices according to the initial slice value and the first change relationship, in the process of uploading the file in slices according to the initial slice value and the first change relationship, the network response speed parameter value is obtained, if the network response speed parameter value does not conform to the preset threshold value, the second change relationship is obtained, wherein the second change relationship represents that the target slice value increases as time increases, and the change rate of the target slice value decreases as time increases, the part of the file that is not uploaded is uploaded in slices according to the second change relationship, and the uploading result of the file is fed back, which realizes dynamic adjustment of the target slice value, so that the slice uploading of the file can adapt to complex and changeable network environment, and not only the efficiency of the file uploading is improved, but also the stability of the file uploading is improved.
[0120] It should be noted that, for the method embodiment, in order to simply describe, all are described as a series of action combinations, but those skilled in the art should know that the embodiment of the application is not limited by the described action order, because according to the embodiment of the application, certain steps can be adopted in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the involved actions are not necessarily the necessary of the embodiment of the application.
[0121] Referring to Figure 5 , a structure schematic diagram of a file processing device provided by an embodiment of the application is shown, which can specifically include the following modules:
[0122] The initial slice value and the first change relationship obtaining module 501 is configured to obtain an initial slice value and a first change relationship in response to a request for uploading a file, wherein the first change relationship represents that a target slice value of the file increases at a preset rate with an increase of time;
[0123] The first slice uploading module 502 is configured to perform slice uploading on the file according to the initial slice value and the first change relationship;
[0124] The network response speed parameter value obtaining module 503 is configured to obtain a network response speed parameter value in the process of performing slice uploading on the file according to the initial slice value and the first change relationship;
[0125] The second change relationship obtaining module 504 is configured to obtain a second change relationship if the network response speed parameter value does not meet a preset threshold, wherein the second change relationship represents that the target slice value increases with an increase of time, and a change rate of the target slice value decreases with an increase of time;
[0126] The second slice uploading module 505 is configured to perform slice uploading on a part of the file that has not been uploaded according to the second change relationship;
[0127] The uploading result feedback module 506 is configured to feed back an uploading result of the file.
[0128] In some embodiments of the present application, the device further comprises:
[0129] The third slice uploading module is configured to perform slice uploading on the part of the file that has not been uploaded according to the second change relationship in the process of performing slice uploading on the part of the file that has not been uploaded according to the second change relationship:
[0130] obtain a maximum slice value;
[0131] if the target slice value is greater than or equal to the maximum slice value, perform slice uploading on the part of the file that has not been uploaded according to the maximum slice value.
[0132] In some embodiments of the present application, the device further comprises:
[0133] The first network environment data obtaining module is configured to obtain first network environment data, wherein the first network environment data is network environment data corresponding to a first network connected by a client, and the network environment data includes one or more of the following: network connection type, network bandwidth information, communication protocol information;
[0134] The network environment index value obtaining module is configured to determine a network environment index value of the first network according to the first network environment data;
[0135] The initial slice value and the maximum slice value determination module is configured to determine the initial slice value and the maximum slice value according to the network environment index value.
[0136] In some embodiments of the present application, the first slice uploading module 502 comprises:
[0137] The first slice uploading submodule is configured to upload the file in slices with the initial slice value as the target slice value, and increase the target slice value according to the first change relationship at a first preset time interval; wherein in adjacent time intervals, the target slice value of the latter time interval is a preset multiple of the target slice value of the former time interval.
[0138] In some embodiments of the present application, the second change relationship is a logarithmic function relationship, and the logarithmic function relationship further comprises a preset constant. The second slice uploading module 505 comprises:
[0139] The target slice value determination submodule is configured to determine the target slice value according to the second change relationship, and upload the part of the file that has not been uploaded in slices according to the target slice value;
[0140] The target slice value adjustment module is configured to increase the target slice value according to the second corresponding relationship at a second preset time interval; wherein in adjacent time intervals, the target slice value of the latter time interval and the target slice value of the former time interval satisfy the logarithmic function relationship.
[0141] The device further comprises:
[0142] The second network environment data acquisition module is configured to acquire second network environment data in response to the operation of switching the network connection of the client; wherein the second network environment data is network environment data corresponding to a second network to which the client is connected after switching the network connection;
[0143] The second network environment index value determination module is configured to determine a second network environment index value of the second network according to the second network environment data;
[0144] The initial slice value and the maximum slice value resetting module is configured to reset the initial slice value and the maximum slice value according to the second network environment index value.
[0145] In some embodiments of the present application, the device further comprises:
[0146] The uploading data saving module is configured to save uploading data of each slice of the file; wherein the uploading data comprises one or more of the following: the target slice value corresponding to each slice, the serial number corresponding to each slice, the size information of the file, and the unique identifier corresponding to each slice.
[0147] an uploading judging module, configured to judge whether there is a failed uploading slice;
[0148] a retransmission module, configured to reupload the failed uploading slice according to the uploading data if there is a failed uploading slice.
[0149] Some embodiments of the present application further provide an electronic device, which can include a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and the computer program is executed by the processor to implement the method for processing a file.
[0150] Some embodiments of the present application further provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method for processing a file.
[0151] Some embodiments of the present application further provide a computer program product, which includes a computer program, and the computer program is executed by a processor to implement the method for processing a file.
[0152] For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the related parts refer to the parts of the method embodiments.
[0153] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of the related data need to comply with the relevant laws, regulations and standards of the country and region, and provide corresponding operation entrances for the user to choose authorization or refusal.
[0154] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other.
[0155] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, device, or computer program product. Therefore, the embodiments of the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program code.
[0156] The embodiments of the present application are described with reference to the flowchart illustrations and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal devices to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal devices, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0157] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal devices to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0158] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal devices, such that a series of operational steps are performed on the computer or other programmable terminal devices to produce a computer implemented process so that the instructions which execute on the computer or other programmable terminal devices provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams.
[0159] Although preferred embodiments of the present application have been described, those skilled in the art will be able to make additional modifications and variations to these embodiments without departing from the scope of the present application. Accordingly, the appended claims are intended to encompass all such modifications and variations as falling within the scope of the present application.
[0160] Finally, it needs to be pointed out that in this document, relational terms such as first and second and the like can only be intended to distinguish one entity or operation from another entity or operation without necessarily requiring or implying any such actual relationship or order between such entities or operations. Moreover, the terms "comprising", "including", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus including the stated element.
[0161] The above provides a detailed description of the method and device of the file processing provided, electronic equipment, storage medium, the principle and implementation of the present application is described in this paper, the above example is only used to help understand the method and core idea of the present application; At the same time, for those skilled in the art, according to the idea of the present application, the specific implementation and application range will be changed; In view of the above, the content of the specification should not be understood as a limitation of the present application.
Claims
1. A method for document processing, characterized in that, The method includes: In response to a request to upload a file, an initial fragment value and a first change relationship are obtained; wherein, the first change relationship represents that the target fragment value of the file increases by a preset multiple as time increases; The file is uploaded in segments based on the initial segment value and the first change relationship; During the process of uploading the file in chunks based on the initial chunk value and the first change relationship, the network response speed parameter value is obtained; If the network response speed parameter value does not meet the preset threshold, a second change relationship is obtained; wherein, the second change relationship represents that the target fragment value increases with time, and the rate of change of the target fragment value decreases with time. Based on the second change relationship, the incomplete upload portion of the file is uploaded in segments; The second change relationship is a logarithmic function relationship, which also includes a preset constant. The step of uploading the incomplete portion of the file in segments according to the second change relationship includes: The target fragment value is determined based on the second change relationship, and the incomplete part of the file is uploaded in fragments according to the target fragment value; The target slice value is increased according to the second preset time interval and the second change relationship; wherein, in adjacent time intervals, the target slice value of the later time interval and the target slice value of the previous time interval satisfy the logarithmic function relationship; The upload result of the file will be displayed.
2. The method according to claim 1, characterized in that, In the process of uploading the incomplete portion of the file according to the second change relationship, the method further includes: Get the maximum fragment value; If the target fragment value is greater than or equal to the maximum fragment value, then the incomplete portion of the file is uploaded in fragments according to the maximum fragment value.
3. The method according to claim 2, characterized in that, Before obtaining the initial shard value, the method further includes: Obtain first network environment data; wherein, the first network environment data is the network environment data corresponding to the first network connected to the client, and the network environment data includes one or more of the following: network connection type, network bandwidth information, and communication protocol information; Based on the first network environment data, determine the network environment index value of the first network; The initial fragmentation value and the maximum fragmentation value are determined based on the network environment index values.
4. The method according to any one of claims 1-3, characterized in that, The step of uploading the file in chunks based on the initial chunk value and the first change relationship includes: The file is uploaded in chunks using the initial chunk value as the target chunk value, and the target chunk value is increased according to the first change relationship at a first preset time interval; wherein, in adjacent time intervals, the target chunk value of the later time interval is a preset multiple of the target chunk value of the previous time interval.
5. The method according to claim 3, characterized in that, The method further includes: In response to the client's operation of switching network connections, second network environment data is obtained; wherein, the second network environment data is the network environment data corresponding to the second network to which the client connects after switching network connections; Based on the second network environment data, determine the second network environment index value of the second network; Based on the second network environment index value, the initial fragmentation value and the maximum fragmentation value are re-determined.
6. The method according to any one of claims 1-3, characterized in that, The method further includes: Save the upload data for each segment of the file; wherein the upload data includes one or more of the following: the target segment value corresponding to each segment, the sequence number corresponding to each segment, the size information of the file, and the unique identifier corresponding to each segment; Determine if any fragments failed to upload; If any fragments fail to upload, the failed fragments are re-uploaded based on the uploaded data.
7. A document processing apparatus, characterized in that, The device includes: The initial fragment value and first change relationship acquisition module is used to acquire the initial fragment value and the first change relationship in response to a file upload request; wherein, the first change relationship represents that the target fragment value of the file increases by a preset multiple as time increases; The first segmented upload module is used to upload the file in segments according to the initial segment value and the first change relationship; The response speed parameter value acquisition module is used to acquire network response speed parameter values during the process of uploading the file in chunks according to the initial chunk value and the first change relationship; The second change relationship acquisition module is used to acquire a second change relationship if the network response speed parameter value does not meet the preset threshold; wherein, the second change relationship represents that the target fragment value increases with time, and the rate of change of the target fragment value decreases with time. The second segmented upload module is used to upload the incomplete portion of the file according to the second change relationship; The second segmented upload module includes: The target fragment value determination submodule is used to determine the target fragment value according to the second change relationship, and to upload the incomplete part of the file according to the target fragment value; The target slice value adjustment module is used to increase the target slice value according to the second change relationship at a second preset time interval; wherein, in adjacent time intervals, the target slice value of the later time interval and the target slice value of the previous time interval satisfy a logarithmic function relationship; The upload result feedback module is used to provide feedback on the upload result of the file.
8. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the file processing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the file processing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
File dynamic fragmentation transmission method and device, equipment and storage medium
CN113765945A
Streaming media resource downloading method and apparatus, and terminal device
WO2016149863A1