Web page-based file transmission method, device and readable storage medium
By determining the optimal number of slices on the web page, the file is sliced and uploaded slice by slice, the problems of reduced transmission speed and high error rate in multi-user concurrent large file transfer are solved, and efficient and stable file transfer is achieved.
Patent Information
- Application Number
- CN202211383683.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-07
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-11-07
AI Technical Summary
When multiple users concurrent large file transmission, limited network bandwidth leads to reduced transmission speed and high transmission error rate, which may lead to web page loading failure and busy servers.
By determining that the current concurrency number does not reach the preset value, the web page controls the file transfer operation to identify the identifier of the file to be uploaded. If there is no identifier in the database and the file size reaches the threshold, the optimal number of slices will be determined based on the file size and bandwidth upload rate, the file slice will be performed and uploaded slice by slice, and file information will be saved, and the breakpoint continuous transmission and file seconds will be supported.
Improve file transfer efficiency, reduce transmission error rate, reduce transmission failure situations, avoid server exceptions, and realize stable large file transfer under high concurrency.
Smart Images

Figure CN115914207B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and more specifically, to a web-based file transmission method, device, and readable storage medium. Background Art
[0002] With the development of big data, existing internet technologies can support the transmission and processing of large files, but they also place higher demands on network bandwidth, network card traffic, and data storage space. When transferring large files via a web page, when multiple people are transferring large files concurrently, the web page needs to execute a large number of operations, which is a heavy task. Furthermore, due to limitations such as network bandwidth and jitter, file transfer speeds can be reduced, and even transmission errors or failures may occur. When too many people are involved, it can lead to web page loading failures, server congestion, and user file transfer inability. Summary of the Invention
[0003] In view of this, the present application provides a web-based file transfer method, device and readable storage medium, which are used to solve the problem that when multiple users transfer large files on the web page, the amount of data transmitted simultaneously is large and the network bandwidth is limited, resulting in a reduced file transfer speed and a high transmission error rate.
[0004] In order to achieve the above objectives, the following solutions are proposed:
[0005] A web page-based file transmission method, comprising:
[0006] Respond to the file transfer request and obtain the current concurrency number, which is the number of files being transferred at a certain moment;
[0007] If the number of concurrent requests does not reach a preset value, and the file transfer request is a file upload request, determining an identifier of the file to be uploaded, wherein the identifier is determined according to the file content;
[0008] When the identifier of the file to be uploaded does not exist in the database, obtaining the file size of the file to be uploaded and the bandwidth upload rate at the current moment;
[0009] If the file size reaches a first threshold, determining an optimal number of slices according to the file size and the bandwidth upload rate, the optimal number of slices being the number of slices corresponding to the shortest upload time of the file to be uploaded;
[0010] Slicing the file to be uploaded according to the optimal number of slices to obtain slice files, and determining an identifier for each slice file;
[0011] The slice files are uploaded in sequence according to the slicing order, and the file information of the files to be uploaded is saved in the database, wherein the file information includes the slice files, the identifiers of the slice files and the identifiers of the files to be uploaded.
[0012] Preferably, it also includes:
[0013] If the concurrency number does not reach the preset value, and the file transfer request is a file download request, obtaining file information of the file to be downloaded;
[0014] Determine whether the file information of the file to be downloaded includes a slice file;
[0015] If the file information of the file to be downloaded includes slice files, the slice files are downloaded in sequence according to the slice order;
[0016] Splice the downloaded slice files to obtain the target file and save it locally;
[0017] If the file information of the file to be downloaded does not include a slice file, the file to be downloaded is directly downloaded to the local computer.
[0018] Preferably, it also includes:
[0019] When the file transfer is interrupted, the resume operation is automatically triggered and the file transfer continues from the slice file where the breakpoint is located.
[0020] Preferably, it also includes:
[0021] When the identifier of the file to be uploaded exists in the database, the data in the database corresponding to the identifier of the file to be uploaded is mapped to the file information of the file to be uploaded, and the file information is saved in the database.
[0022] Preferably, uploading the slice files in sequence according to the slice order includes:
[0023] Determine in sequence according to the slice order whether the identifier of the slice file exists in the database;
[0024] If the identifier of the slice file exists in the database, the data corresponding to the identifier of the slice file in the database is mapped to the slice file to complete the upload;
[0025] If the identifier of the slice file does not exist in the database, the slice file is uploaded.
[0026] Preferably, it also includes:
[0027] If the file size does not reach the first threshold, the file to be uploaded is directly uploaded, and file information of the file to be uploaded is saved in the database, where the file information includes the file to be uploaded and an identifier of the file to be uploaded.
[0028] Preferably, determining the optimal number of slices according to the file size and the bandwidth upload rate includes:
[0029] Input the file size and the bandwidth upload rate into a pre-established data analysis model, and when the upload time of the file to be uploaded in the data analysis model is a minimum value, the corresponding number of slices is the optimal number of slices;
[0030] The data analysis model is used to reflect the constraint relationship between the upload time and the number of slices. The file upload time is determined by the file size, bandwidth upload rate, interface response time and number of slices. The upload time includes identifier calculation time, file slicing time, slice file upload time and interface response time.
[0031] Preferably, it also includes:
[0032] If the number of concurrent requests reaches a preset value, a timeout prompt message is sent to the user, and the timeout prompt message is used to prompt the user to send the file transfer request again after a preset time.
[0033] A web-based file transmission device, comprising:
[0034] The transmission process control unit is used to respond to the file transfer request and obtain the current concurrency number, which is the number of files being transferred at a certain moment;
[0035] A file identification recording unit, configured to determine an identifier of a file to be uploaded when the number of concurrent requests does not reach a preset value and the file transfer request is a file upload request, wherein the identifier is determined according to the file content;
[0036] a slice information obtaining unit, for obtaining the file size of the file to be uploaded and the current bandwidth upload rate when the identifier of the file to be uploaded does not exist in the database;
[0037] a slice parameter adjustment unit, configured to determine an optimal number of slices according to the file size and the bandwidth upload rate when the file size reaches a first threshold, the optimal number of slices being the number of slices corresponding to the shortest upload time of the file to be uploaded;
[0038] a file slicing unit, configured to slice the file to be uploaded according to the optimal number of slices to obtain slice files, and determine an identifier for each slice file;
[0039] The slicing file uploading unit is used to upload the slicing files in sequence according to the slicing order, and save the file information of the file to be uploaded to the database, wherein the file information includes the slicing file, the identifier of the slicing file and the identifier of the file to be uploaded.
[0040] Preferably, it also includes:
[0041] A file information acquiring unit, configured to acquire file information of a file to be downloaded when the number of concurrent requests does not reach a preset value and the file transfer request is a file download request;
[0042] a slice file query unit, configured to determine whether the file information contains a slice file;
[0043] a slice file downloading unit, configured to download the slice files in sequence according to a slice order when the file information includes the slice files;
[0044] A slice file splicing unit is used to splice the downloaded slice files to obtain a target file and save it locally;
[0045] The file downloading unit is used to directly download the file to be downloaded to the local computer when the file information does not include a slice file.
[0046] Preferably, it also includes:
[0047] The breakpoint resume unit is used to automatically trigger the resume operation when the file transfer is interrupted, and continue to transfer the file from the slice file where the breakpoint is located.
[0048] Preferably, it also includes:
[0049] The data mapping unit is used to map the data corresponding to the identifier of the file to be uploaded in the database to the file information of the file to be uploaded when the identifier of the file to be uploaded exists in the database, and save the file information in the database.
[0050] Preferably, it also includes:
[0051] The prompt information sending unit is used to send a timeout prompt information to the user when the concurrency number reaches a preset value, and the timeout prompt information is used to prompt the user to send the file transfer request again after a preset time.
[0052] A readable storage medium stores a computer program, which, when executed by a processor, implements the various steps of the aforementioned web-based file transmission method.
[0053] As can be seen from the above technical solution, the embodiment of the present application provides a web-based file transfer method, which controls the web page to start the file transfer operation by determining that the current concurrency number has not reached a preset value. When a file upload request is identified, the identifier of the file to be uploaded is determined. If the identifier does not exist in the database and the file size reaches a first threshold, the optimal number of slices that minimizes the upload time of the file to be uploaded is determined based on the file size and the current bandwidth upload rate. The file is sliced according to the optimal number of slices, the identifier of each slice file is determined, and the file information of the file to be uploaded is uploaded and saved slice by slice. This solution effectively improves the file transmission efficiency by slicing large files transmitted based on the web page and adjusting the optimal number of slices based on the file size and bandwidth upload rate to minimize the file upload time. At the same time, when an exception occurs in the file transfer process, it can ensure that the uploaded or downloaded slice files are not affected, thereby reducing the transmission error rate and the number of transmission failures. In addition, through concurrency control, the number of files being transferred can be controlled within a reasonable range, avoiding server exceptions when multiple people are transferring files at the same time, thereby achieving large file transfer under high concurrency. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0055] Figure 1 A flowchart of a web-based file transfer method disclosed in an embodiment of the present application;
[0056] Figure 2 This is a flow chart of another web-based file transfer method disclosed in an embodiment of the present application;
[0057] Figure 3 This is a schematic diagram of the structure of a web-based file transmission device disclosed in an embodiment of the present application;
[0058] Figure 4 This is a schematic diagram of the structure of another web-based file transfer device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0060] The investigation found that in the existing technology, in order to control the configuration parameters required for the file transfer process within a certain range and reduce development costs, researchers proposed a file slicing method. When uploading files, the files are sliced and divided into small slice files, which are transmitted in sequence. When downloading files, they are downloaded in the order of slices, and the complete downloaded file is obtained by file splicing. When the file transfer is interrupted and needs to be retransmitted, the transmission can be continued at the breakpoint. In addition, the file can be transferred in seconds by recording the unique identification MD5 value of the file.
[0061] After further research, the inventors found that although the above-mentioned file slicing method is suitable for the file transfer process on the web side, due to the limitation of network bandwidth, when multiple users perform file transfer operations at the same time, the transmission speed will still be greatly affected, resulting in a high error rate in the file transfer process.
[0062] In view of this, the inventor proposed a file transmission method based on web pages, see Figure 1 , Figure 1 A flowchart of a web-based file transfer method disclosed in an embodiment of the present application is shown as follows: Figure 1 As shown, the process may include:
[0063] Step S10: Respond to the file transfer request and obtain the current concurrent number.
[0064] Specifically, when the web page receives a file transfer request sent by a user, it determines whether the current network parameters support the execution of the file transfer operation based on the concurrency number obtained at the current moment.
[0065] Among them, the concurrency number at the current moment can be the number of files being transferred at the current moment, the total size of files being transferred at the current moment, or the number of users performing file transfer operations at the current moment. By judging whether the concurrency number meets the execution conditions before transferring files, it is determined whether the current file transfer request can be passed and the file transfer can be started.
[0066] Step S11: If the number of concurrent requests does not reach the preset value and the file transfer request is a file upload request, determine the identifier of the file to be uploaded.
[0067] If the number of concurrent requests does not reach the preset value, it indicates that the current network parameters meet the execution conditions, and the file transfer begins. If the file transfer request sent by the user is an upload request, indicating that the user needs to upload a file from the local computer to the cloud or database, the operation that begins is the file upload operation.
[0068] Furthermore, upon receiving the upload instruction, the web page can obtain the file to be uploaded. When uploading the file, the web page first determines the identifier of the file to be uploaded. The identifier, as a unique identifier of the file, can be calculated based on the file content. In one optional case, the identifier can be an MD5 value. The MD5 value of the file can be calculated using a message digest algorithm. When the file contents are completely identical, the corresponding MD5 values are the same. However, when the file contents of the two files are different, the calculated MD5 values are also different.
[0069] Optionally, if the number of concurrent requests reaches a preset value, it means that the current network is busy and the maximum file transfer volume has been reached. The user's current file transfer operation is not supported. At this time, a timeout prompt message can be sent to the user, such as "Loading timeout, please execute later." or "There are too many people at present, please upload / download again after 5 minutes." and other information to prompt the user to resend the file transfer request later.
[0070] Step S12: If the identifier of the file to be uploaded does not exist in the database, the file size of the file to be uploaded and the bandwidth upload rate at the current moment are obtained.
[0071] Specifically, by searching for the identifier of the file to be uploaded in the database, it can be determined whether the file to be uploaded has been uploaded. If the identifier does not exist in the database, it means that the file to be uploaded has not been uploaded, and the upload operation is continued to obtain the file size of the file to be uploaded and the current bandwidth upload rate.
[0072] Among them, file size and bandwidth upload rate are objective parameters that can affect file upload time. The bandwidth upload rate represents the data transmission rate when a user sends information to the internet, that is, the speed of uploading information, also known as the uplink rate. Its corresponding downlink rate represents the data transmission rate when the internet sends information to the user, that is, the speed of downloading information. Generally speaking, to prevent network congestion, the uplink rate is usually lower than the downlink rate. For example, for a 100M network bandwidth, the theoretical download speed is 100M / 8 = 12.5M bytes per second (Mbps). The actual download speed is above 11.25Mbps and is within the normal range. If the corresponding uplink bandwidth is 20M, the theoretical upload speed is 20M / 8 = 2.5Mbps. The actual upload speed is above 2.25Mbps and is within the normal range.
[0073] Optionally, when the identifier exists in the database, it means that the file to be uploaded has been uploaded to the database. At this time, the file can be directly uploaded in seconds through data mapping without having to upload it again.
[0074] Step S13: If the file size reaches a first threshold, determine the optimal number of slices based on the file size and the bandwidth upload rate. The optimal number of slices is the number of slices corresponding to the shortest upload time for the file to be uploaded.
[0075] Specifically, when it is determined that the file upload operation needs to be continued, whether the file to be uploaded needs to be sliced and uploaded can be determined by judging whether the file size of the file to be uploaded reaches a first threshold. When the file size reaches the first threshold, it indicates that the file is too large and the file slicing step needs to be performed. The first threshold can be calculated by establishing a theoretical model or obtained through experimental statistical analysis. The first threshold can be the file size corresponding to the maximum critical point that makes the file upload time reach a reasonable range.
[0076] Furthermore, after determining that the file to be uploaded needs to be sliced, the number of slices is first determined, representing the number of slice files obtained after slicing. Optionally, based on the file size and bandwidth upload rate values obtained in the above steps, the number of slices that can minimize the file upload time can be found and determined as the optimal number of slices, thereby obtaining the optimal slicing solution.
[0077] Optionally, if the file size does not reach the first threshold, it can be uploaded directly without performing a slicing operation, and the file to be uploaded and the identifier are saved in the database after the upload is completed.
[0078] Step S14: Slice the file to be uploaded according to the optimal number of slices to obtain slice files, and determine the identifier of each slice file.
[0079] Specifically, the file to be uploaded is split into small slice files according to the optimal number of slices determined above. Since the contents of the slice files obtained after segmentation are not completely consistent with the contents of the file to be uploaded, the identifier of each slice file is different from the identifier of the file to be uploaded. At the same time, the identifier of each slice file is unique. Therefore, after obtaining the slice files, the identifier of each slice file can be further determined.
[0080] Step S15: Upload the slice files in sequence according to the slicing order, and save the file information of the file to be uploaded into the database. The file information includes the slice file, the identifier of the slice file and the identifier of the file to be uploaded.
[0081] Specifically, the slice files are uploaded in sequence according to the order of file slicing in the above steps. After all slice files are uploaded, the slice files and identifiers and other file information are saved in the database. The identifier may include the identifier of the file to be uploaded and the identifier of each slice file.
[0082] Optionally, when the upload is interrupted due to human factors or force majeure factors such as network outage and power outage, the breakpoint resume function will be automatically triggered after the upload is restored to normal, returning to the original upload progress, re-uploading the slice file at the breakpoint position, and continuing to upload subsequent slice files. The slice files that have been uploaded before the interruption do not need to be re-uploaded.
[0083] Furthermore, before uploading the slice file, you can check whether the identifier of the slice file exists in the database. If the identifier exists, it means that the slice file has been uploaded and there is no need to upload it again. You can directly link the data mapped by the identifier to the slice file to complete the upload of the slice file. If the identifier does not exist, execute the slice file upload operation.
[0084] The web page-based file transfer method provided by this embodiment determines that the current concurrency number has not reached a preset value, controls the web page to start executing the file transfer operation, and when a file upload request is identified, determines the identifier of the file to be uploaded. If the identifier does not exist in the database and the file size reaches a first threshold, then determines the optimal number of slices that minimizes the upload time of the file to be uploaded based on the file size and the current bandwidth upload rate. The file is sliced according to the optimal number of slices, the identifier of each slice file is determined, and the file information of the file to be uploaded is uploaded and saved slice by slice. The present application scheme slices large files transmitted based on the web page and adjusts the optimal number of slices based on the file size and bandwidth upload rate to minimize the file upload time, effectively improving the file transmission efficiency. At the same time, when an exception occurs in the file transmission process, it can ensure that the uploaded or downloaded slice files are not affected, thereby reducing the transmission error rate and the number of transmission failures. At the same time, the transmission can be continued from the transmission interruption point, with an error handling mechanism and the ability to automatically retransmit errors, which not only reduces the error rate but also saves the user the time of manually clicking to retransmit.
[0085] In addition, each uploaded file is effectively marked with an identifier. When the same file is transferred again, the link mapping data can be used to achieve instant file transfer. At the same time, when the identifier of a slice file has mapping data, it can automatically skip the slice and execute the upload operation of the subsequent slice, further saving upload time. Furthermore, concurrency control can control the amount of data being transferred within a reasonable range, avoiding server anomalies when multiple people transfer files simultaneously, thus achieving large file transfer under high concurrency.
[0086] Further, see Figure 2 , Figure 2 FIG. 1 shows another flow chart of a web-based file transmission method disclosed in an embodiment of the present application. Figure 2 As shown, the process may include:
[0087] Step S20: Respond to the file download request and obtain the current concurrent number.
[0088] In an optional case, the file transfer request sent by the user may be a file download request.
[0089] This step corresponds to step S10 in the aforementioned embodiment. Please refer to the aforementioned introduction for details and will not be repeated here.
[0090] Step S21: If the number of concurrent downloads does not reach the preset value, obtain the file information of the file to be downloaded.
[0091] Specifically, when the file transfer request is a file download request, it is determined that the concurrency count has not reached a preset value, indicating that the user needs to download the file from the cloud or database to the local computer, and the file download operation is then executed. Furthermore, upon receiving the download instruction, the webpage can obtain the file address of the file to be downloaded. When downloading a file, the webpage first obtains the file information of the file to be downloaded.
[0092] Optionally, for the case where the number of concurrent requests reaches a preset value, reference may be made to the relevant introduction in step S11 of the aforementioned embodiment, which will not be repeated here.
[0093] Step S22: Determine whether the file information includes a slice file.
[0094] The file information may include a slice file and an identifier of the file to be downloaded. Whether the file to be downloaded is a sliced file can be determined by determining whether the file information includes the slice file.
[0095] Optionally, whether a slice file is included can be determined by determining the number of identifiers recorded in the file information. If there is only one identifier in the file information, it means that the file to be downloaded does not include a slice file, and the identifier is the identifier of the file to be downloaded. If the file information contains more than two identifiers, it means that the file to be downloaded includes a slice file, and the identifier includes the identifier of the file to be downloaded and the identifier of the slice file. Therefore, if the file is sliced, the number of identifiers included in its file information is at least three.
[0096] Furthermore, the system can optionally search for a local file with the same identifier as the file to be downloaded in the target download directory set by the user. If no local file exists, the system continues to perform subsequent download steps. If no local file exists, the system indicates that the file to be downloaded has been downloaded to the local target download directory. At this time, a prompt message can be sent to the user to determine whether the user needs to download the file again. The user can then choose to continue or cancel the download. If the user chooses to cancel the download, the download process is exited. If the user chooses to continue the download, the download operation is continued and the file to be downloaded is renamed to distinguish between two identical files in the same directory.
[0097] Step S23: When the file information includes slice files, the slice files are downloaded in sequence according to the slicing order.
[0098] When the file information of the file to be downloaded contains slice files, all slice files are downloaded and can be downloaded in sequence according to the slice order.
[0099] Optionally, when the download is interrupted due to human factors or force majeure factors such as network outage and power outage, the breakpoint resume function will be automatically triggered after the download is restored to normal, returning to the original download progress, re-downloading the slice file at the breakpoint position, and continuing to download subsequent slice files. The slice files that have been downloaded before the interruption do not need to be re-downloaded.
[0100] Step S24: Splice the downloaded slice files to obtain the target file and save it locally.
[0101] Specifically, after all slice files are downloaded, they can be spliced together in the order of slicing or downloading, and the split fragment files can be restored into a complete target file to obtain the file the user needs to obtain. Furthermore, the spliced target file is saved to the local download directory pre-set by the user, completing the file download operation.
[0102] Step S25: When the file information does not include a slice file, the file to be downloaded is directly downloaded to the local computer.
[0103] When the file information of the file to be downloaded does not contain a slice file, the file information stores a complete file to be downloaded. At this time, the file to be downloaded is directly downloaded to the local download directory preset by the user to complete the file download operation.
[0104] In this embodiment, the file transfer request sent by the user is a file download request. When the concurrency number does not reach the preset value, it is determined whether the file information of the file to be downloaded contains a slice file. If the slice file is contained, the slice file is spliced and downloaded. By automatically triggering the breakpoint re-download mechanism when the download fails, the file download efficiency is improved, and the download error rate is reduced. This effectively ensures the integrity and accuracy of users downloading large files on the web page.
[0105] Next, the embodiment of the present application further introduces in detail an optional implementation method for determining the optimal number of slices in the above step S13.
[0106] As described in the previous embodiments, the optimal number of slices can be determined by finding the number of slices that minimizes file upload time based on file size and bandwidth upload rate. Alternatively, a data analysis model can be established for file upload time and number of slices, and the optimal number of slices can be calculated using the model.
[0107] Specifically, since the main influencing factors of file upload time may include identifier calculation time, file slicing time, sliced file upload time and interface response time, a function for calculating file upload time can be established as a data analysis model.
[0108] Assuming that the identifier calculation time is linearly correlated with the file size, file size can be used as a key parameter in determining file upload time. Furthermore, since file slicing time is related to the number of slices, and slice file upload time is related to the bandwidth upload rate, the number of slices and bandwidth upload rate can also be used as key parameters in determining file upload time. Interface response time can be obtained through specific software. Therefore, the data analysis model can be a functional relationship established between file upload time and the number of slices, file size, bandwidth upload rate, and interface response time.
[0109] Alternatively, by inputting the acquired parameters, such as file size, bandwidth upload rate, and interface response time, into the established functional relationship, a binary equation can be derived relating file upload time T to the number of slices n. Further data analysis can be performed to calculate the optimal solution to this binary equation. Specifically, the optimal solution refers to the solution of the equation corresponding to the minimum value of file upload time T when the number of slices n is a positive integer. The number of slices n corresponding to the optimal solution is the optimal number of slices.
[0110] In this embodiment, a data analysis model for calculating file upload time is established, the values of parameters such as file size, bandwidth upload rate and interface response time are input into the model, a binary equation about file upload time and number of slices is determined, and the optimal solution is further calculated. The number of slices corresponding to the optimal solution is determined as the optimal number of slices. Determining the optimal number of slices by establishing a model can ensure the accuracy of the calculation results, effectively shorten the file upload time, and thus improve the file transmission efficiency.
[0111] The following describes a web page-based file transmission device provided in an embodiment of the present application. The web page-based file transmission device described below and the web page-based file transmission method described above can refer to each other.
[0112] First, combine Figure 3 , introduces a web-based file transmission device disclosed in an embodiment of the present application, such as Figure 3 As shown, the device may include:
[0113] The transmission process control unit 100 is used to respond to the file transmission request and obtain the current concurrency number, which is the number of files being transmitted at a certain moment;
[0114] A file identification recording unit 110 is configured to determine an identifier of a file to be uploaded when the number of concurrent requests does not reach a preset value and the file transfer request is a file upload request, wherein the identifier is determined according to the file content;
[0115] The slice information obtaining unit 120 obtains the file size of the file to be uploaded and the current bandwidth upload rate when the identifier of the file to be uploaded does not exist in the database;
[0116] a slice parameter adjustment unit 130 configured to determine an optimal number of slices according to the file size and the bandwidth upload rate when the file size reaches a first threshold, the optimal number of slices being the number of slices corresponding to the shortest upload time of the file to be uploaded;
[0117] A file slicing unit 140 is configured to slice the file to be uploaded according to the optimal number of slices to obtain slice files, and determine an identifier for each slice file;
[0118] The slice file uploading unit 150 is used to upload the slice files in sequence according to the slicing order, and save the file information of the file to be uploaded to the database. The file information includes the slice file, the identifier of the slice file and the identifier of the file to be uploaded.
[0119] Optionally, the slice parameter adjustment unit 130 may include:
[0120] a slice parameter determination unit, configured to input the file size and the bandwidth upload rate into a pre-established data analysis model, and when the upload time of the file to be uploaded in the data analysis model is a minimum value, the corresponding number of slices is the optimal number of slices;
[0121] A model building unit is used to establish the data analysis model, which is used to reflect the constraint relationship between the upload time and the number of slices. The file upload time is determined by the file size, bandwidth upload rate, interface response time and number of slices. The upload time includes identifier calculation time, file slicing time, slice file upload time and interface response time.
[0122] Optionally, the slice file uploading unit 150 may include:
[0123] A first determining unit is configured to determine, in sequence according to the slice order, whether an identifier of the slice file exists in the database;
[0124] a slice data mapping unit, configured to map data corresponding to the identifier of the slice file in the database to the slice file when the identifier of the slice file exists in the database, thereby completing the upload;
[0125] The slice data uploading unit is used to upload the slice file when the identifier of the slice file does not exist in the database.
[0126] Optionally, the web page-based file transmission device provided by this application may further include:
[0127] The data mapping unit is used to map the data corresponding to the identifier of the file to be uploaded in the database to the file information of the file to be uploaded when the identifier of the file to be uploaded exists in the database, and save the file information in the database.
[0128] The file uploading unit is configured to directly upload the file to be uploaded when the file size does not reach a first threshold, and save file information of the file to be uploaded into the database, wherein the file information includes the file to be uploaded and an identifier of the file to be uploaded.
[0129] The breakpoint resume unit is used to automatically trigger the resume operation when the file transfer is interrupted, and continue to transfer the file from the slice file where the breakpoint is located.
[0130] The prompt information sending unit is used to send a timeout prompt information to the user when the concurrency number reaches a preset value, and the timeout prompt information is used to prompt the user to send the file transfer request again after a preset time.
[0131] Further, combined Figure 4, another web-based file transmission device disclosed in the embodiment of the present application is introduced, such as Figure 4 As shown, the device may include:
[0132] The transmission process control unit 200 is used to respond to the file transmission request and obtain the current concurrency number, which is the number of files being transmitted at a certain moment;
[0133] The file information obtaining unit 210 is configured to obtain file information of a file to be downloaded when the number of concurrent requests does not reach a preset value and the file transfer request is a file download request;
[0134] a slice file query unit 220, configured to determine whether the file information includes a slice file;
[0135] The slice file downloading unit 230 is configured to download the slice files in sequence according to the slice order when the file information includes the slice files;
[0136] The slice file splicing unit 240 is used to splice the downloaded slice files to obtain a target file and save it locally;
[0137] The file downloading unit 250 is used to directly download the file to be downloaded to the local computer when the file information does not include a slice file.
[0138] Optionally, the web page-based file transmission device provided by this application may further include:
[0139] The breakpoint resume unit is used to automatically trigger the resume operation when the file transfer is interrupted, and continue to transfer the file from the slice file where the breakpoint is located.
[0140] An embodiment of the present application further provides a readable storage medium, which may store a program suitable for execution by a processor, wherein the program is used to implement various processing flows in the aforementioned web-based file transfer solution.
[0141] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0142] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0143] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A file transmission method based on a web page, characterized in that: include: Respond to the file transfer request and obtain the current concurrency number, which is the number of files being transferred at a certain moment; If the number of concurrent requests does not reach a preset value, and the file transfer request is a file upload request, determining an identifier of the file to be uploaded, wherein the identifier is determined according to the file content; When the identifier of the file to be uploaded does not exist in the database, obtaining the file size of the file to be uploaded and the bandwidth upload rate at the current moment; If the file size reaches a first threshold, determining an optimal number of slices according to the file size and the bandwidth upload rate, the optimal number of slices being the number of slices corresponding to the shortest upload time of the file to be uploaded; Slicing the file to be uploaded according to the optimal number of slices to obtain slice files, and determining an identifier for each slice file; The slice files are uploaded in sequence according to the slicing order, and the file information of the files to be uploaded is saved in the database, wherein the file information includes the slice files, the identifiers of the slice files and the identifiers of the files to be uploaded.
2. The method according to claim 1, characterized in that Also includes: If the concurrency number does not reach the preset value, and the file transfer request is a file download request, obtaining file information of the file to be downloaded; Determine whether the file information of the file to be downloaded includes a slice file; If the file information of the file to be downloaded includes slice files, the slice files are downloaded in sequence according to the slice order; Splice the downloaded slice files to obtain the target file and save it locally; If the file information of the file to be downloaded does not include a slice file, the file to be downloaded is directly downloaded to the local computer.
3. The method according to claim 1 or claim 2, characterized in that Also includes: When the file transfer is interrupted, the resume operation is automatically triggered and the file transfer continues from the slice file where the breakpoint is located.
4. The method according to claim 1, wherein Also includes: When the identifier of the file to be uploaded exists in the database, the data in the database corresponding to the identifier of the file to be uploaded is mapped to the file information of the file to be uploaded, and the file information is saved in the database.
5. The method according to claim 1, wherein The step of uploading the slice files in sequence according to the slice order includes: Determine in sequence according to the slice order whether the identifier of the slice file exists in the database; If the identifier of the slice file exists in the database, the data corresponding to the identifier of the slice file in the database is mapped to the slice file to complete the upload; If the identifier of the slice file does not exist in the database, the slice file is uploaded.
6. The method according to claim 1, characterized in that Also includes: If the file size does not reach the first threshold, the file to be uploaded is directly uploaded, and file information of the file to be uploaded is saved in the database, where the file information includes the file to be uploaded and an identifier of the file to be uploaded.
7. The method according to claim 1, characterized in that The determining the optimal number of slices according to the file size and the bandwidth upload rate includes: Input the file size and the bandwidth upload rate into a pre-established data analysis model, and when the upload time of the file to be uploaded in the data analysis model is a minimum value, the corresponding number of slices is the optimal number of slices; The data analysis model is used to reflect the constraint relationship between the upload time and the number of slices. The file upload time is determined by the file size, bandwidth upload rate, interface response time and number of slices. The upload time includes identifier calculation time, file slicing time, slice file upload time and interface response time.
8. The method according to claim 1, characterized in that Also includes: If the number of concurrent requests reaches a preset value, a timeout prompt message is sent to the user, and the timeout prompt message is used to prompt the user to send the file transfer request again after a preset time.
9. A web-based file transmission device, characterized in that: include: The transmission process control unit is used to respond to the file transfer request and obtain the current concurrency number, which is the number of files being transferred at a certain moment; A file identification recording unit, configured to determine an identifier of a file to be uploaded when the number of concurrent requests does not reach a preset value and the file transfer request is a file upload request, wherein the identifier is determined according to the file content; a slice information obtaining unit, for obtaining the file size of the file to be uploaded and the current bandwidth upload rate when the identifier of the file to be uploaded does not exist in the database; a slice parameter adjustment unit, configured to determine an optimal number of slices according to the file size and the bandwidth upload rate when the file size reaches a first threshold, the optimal number of slices being the number of slices corresponding to the shortest upload time of the file to be uploaded; a file slicing unit, configured to slice the file to be uploaded according to the optimal number of slices to obtain slice files, and determine an identifier for each slice file; The slicing file uploading unit is used to upload the slicing files in sequence according to the slicing order, and save the file information of the file to be uploaded to the database, wherein the file information includes the slicing file, the identifier of the slicing file and the identifier of the file to be uploaded.
10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the web-based file transmission method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method and device for converting spreadsheet file into web format file
CN103324731A
Mirror image file uploading method, related equipment and computer storage medium
CN113411363A