File uploading method and client, device, storage medium and program product
By introducing plug-ins to interact with the browser in the client, generating upload tasks and establishing communication connections with the server, the problem of file upload dependence on the browser in the existing technology is solved, and efficient and stable file upload and batch upload functions are realized.
Patent Information
- Application Number
- CN202410816421.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-12-20
AI Technical Summary
The existing file upload method depends on the browser, resulting in the problem of upload termination after the browser is closed, the calculation of MD5 is expensive, the transmission efficiency is low when the files are large or many, the interruption point is inconvenient, and the problem of being able to select files but not select folders.
By introducing plug-ins to interact with the browser in the client, generating upload tasks and establishing communication connections with the server, the plug-in can independently complete file upload and synchronous upload progress information, reducing dependence on the browser.
It improves the efficiency and stability of file uploads, supports batch uploads of large files and multiple files, enhances the user experience, and avoids the synchronization consistency of browser status affecting the upload progress.
Smart Images

Figure CN119172374A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network technology, and in particular to a file uploading method and a client, a device, a storage medium, and a program product. Background Art
[0002] In various complex web systems, it is inevitable to encounter file uploads, such as when processing business data, you need to upload Excel files; for example, when a video website needs to process video data, it needs to upload multimedia files. When the business is becoming more and more complex, there will be more file uploads, and the file size is large. In the traditional large file upload process, the browser is relied on to select the file. Summary of the invention
[0003] The present invention provides a file uploading method and a client, a device, a storage medium, and a program product, which are used to reduce the dependence of file uploading on a browser and improve the efficiency of file uploading.
[0004] In a first aspect, the present disclosure provides a file upload method, which is applied to a client, wherein the client runs a plug-in and a browser, and the method comprises:
[0005] The browser generates an upload task for the target file and transmits the upload task to the plug-in;
[0006] The plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file, and a first communication connection is established between the plug-in and the server;
[0007] The browser obtains the upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server.
[0008] In a second aspect, the present disclosure provides a client, including a plug-in and a browser;
[0009] The browser is used to generate an upload task for a target file, transmit the upload task to the plug-in; and obtain upload progress information of the target file from the plug-in, save the upload progress information and synchronize the upload progress information to the server;
[0010] The plug-in is used to upload the target file to the server based on the upload task and the first communication connection, and save the upload progress information of the target file. The first communication connection is established between the plug-in and the server.
[0011] In a third aspect, the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can execute the above-mentioned file upload method.
[0012] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned file uploading method when executed by a processor.
[0013] In a fifth aspect, the present disclosure provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned file uploading method.
[0014] In the embodiment provided by the present disclosure, after the plug-in in the client obtains the upload task by interacting with the browser in the client, the target file is uploaded to the server based on the upload task and the first communication connection established between the plug-in and the server. When the plug-in and the server can establish a communication connection normally, the upload process of the target file can be completed through the plug-in without relying on the browser. Even if the browser is disconnected from the server, the upload progress of the target file will not be affected, thereby improving the upload efficiency of the target file. In addition, the browser obtains the upload progress information of the target file from the plug-in and synchronizes the upload progress information of the target file to the server, thereby ensuring the consistency of the upload progress of the target file in the browser and the server, so that the browser can timely know the file upload status, so as to provide it to the user for viewing, and the normal use of the browser will not be affected by the upload of files, including the upload of large files or multiple files.
[0015] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0017] Figure 1A schematic diagram of the file upload process for related technologies;
[0018] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0019] Figure 3 A schematic diagram of a file uploading method applied to a client provided in an embodiment of the present disclosure;
[0020] Figure 4 A schematic diagram of an example of a process of a client uploading a file provided in an embodiment of the present disclosure;
[0021] Figure 5 A schematic diagram of another example of a process of a client uploading a file provided in an embodiment of the present disclosure;
[0022] Figure 6 A schematic diagram of a logic block diagram of a client provided in an embodiment of the present disclosure;
[0023] Figure 7 A schematic block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0025] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0026] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0027] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0028] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0029] The inventors found in the process of implementing the present disclosure that in the existing file upload solution, the browser selects a limited number of files, segments them according to the specified size or number, and the browser directly uploads the segments to the server through the network protocol, which can also ensure the stability of the upload to a certain extent (compared to the whole direct upload), and can realize basic breakpoint resume. Figure 1 The figure shows a schematic diagram of the file upload process of the related technology. For the specific process, please refer to the contents described in steps 101 to 113 in the figure. The file upload process mainly has the following defects:
[0030] (1) It is highly dependent on the browser. Once the browser is closed, the upload will terminate.
[0031] (2) MD5 needs to be calculated to ensure the uniqueness of the file, which results in high computational overhead;
[0032] (3) Due to the limitations of browser capabilities, when selecting a large number of files or large files, the browser may experience lag due to excessive memory usage, which will greatly reduce the transmission efficiency;
[0033] (4) Resuming a breakpoint transfer requires reselecting the same file. When the file size is large, it is difficult to reselect the previously interrupted file, which is not convenient.
[0034] (5) You can only select files by selecting them, and you cannot select the entire folder.
[0035] Based on this, the embodiments of the present disclosure provide a file uploading method to solve the problems existing in uploading files through a browser.
[0036] First, the technical names involved in the embodiments of the present disclosure are explained as follows:
[0037] A plug-in is a program written in accordance with a certain standard application program interface, which can run on the system platform specified by the program (it may support multiple platforms at the same time) and cannot run independently from the specified platform. For example, a plug-in can be installed and run in an operating system (Windows).
[0038] The web side, also known as the browser, refers to the browser-based web front-end service, which is presented and interacted through the browser.
[0039] WebSocket is a protocol for full-duplex communication over a single Transmission Control Protocol (TCP) connection. WebSocket makes data exchange between the client and server where the browser is located easier, allowing the server to actively push data to the client. In the WebSocket application programming interface (API), the browser and the server only need to complete a handshake, and a persistent connection can be directly established between the two, and two-way data transmission can be carried out.
[0040] The server provides services to the client where the browser is located. The services include providing resources to the client where the browser is located, saving client data, and interacting with the client for data transmission through various network transmission protocols.
[0041] Components, in short, are objects, which are simple encapsulation of data and methods. Front-end components are parts that make up page content. They are a combination of HyperText Markup Language (HTML) structure and Cascading Style Sheets (CSS), and can integrate certain functions to achieve out-of-the-box use.
[0042] The client provided by the embodiment of the present disclosure includes a browser and a plug-in, wherein the browser itself can be a front-end component, wherein the plug-in and the browser establish a communication connection.
[0043] like Figure 2 As shown, the application scenario of the embodiment of the present disclosure includes a client and a server, wherein the server establishes a communication connection with the client; when the server receives a page access request from the client, it returns page data to the client, and the client displays the page data received from the server; when the client needs to upload a file to the server, it uploads the file through the communication connection established with the server. The client includes a plug-in and a browser, and the plug-in in the client establishes a communication connection with the browser in the client.
[0044] Figure 3 The figure is a flowchart of a method for uploading files applied to a client provided by an embodiment of the present disclosure. The client runs a plug-in and a browser. The method for uploading files by the client mainly includes the following steps:
[0045] Step 301: The browser generates an upload task for a target file and transmits the upload task to the plug-in.
[0046] It should be noted that the target file can be any file to be uploaded, and there are many ways for the browser to generate an upload task for the target file, including but not limited to generating an upload task for the target file based on user operations, or generating an upload task for the target file that is not fully uploaded.
[0047] In some embodiments, the browser generates an upload task for the target file and transmits the upload task to the plug-in, including: the browser obtains the unique identifier of the target file that needs to be uploaded to the server by the plug-in, and transmits the upload task of the target file to the plug-in, wherein the upload task includes the unique identifier of the target file.
[0048] It should be noted that the unique identifier of the target file can be used to indicate the identity of a specific client uploading the target file, so as to distinguish it from files uploaded by other clients, or to distinguish it from other target files uploaded by the same specific client. Carrying the unique identifier of the target file in the upload task allows the plug-in to lock the client and the target file according to the unique identifier carried in the upload task, so as to avoid uploading the wrong file.
[0049] Considering that the files saved in the same server may be uploaded by multiple different clients, and one client corresponds to one physical device, in order to be able to distinguish different files and the client responsible for uploading the files through the unique identifier, in one embodiment, the unique identifier of the target file is generated according to the absolute address of the target file and the unique identifier of the client (i.e., the plug-in), and the unique identifier of the client is generated according to the physical address of the device where the client is located. Here, the unique identifier of the file is generated based on the absolute address of the file and the physical address of the device where the client is located, which improves the efficiency of generating the unique identifier of the file, thereby improving the upload efficiency. The unique identifier of the client is also the unique identifier of the plug-in. For example, the unique identifier of the client and the unique identifier of the plug-in are both the physical address of the device where the client is located.
[0050] Absolute address, which is the absolute address of the target file in the memory, refers to an address scheme in communications, computers and data processing systems. This address directly identifies a storage unit without using related media, such as a base station address or a relative address.
[0051] Exemplarily, a combination of the absolute address of the target file and the unique identifier of the client is directly used as the unique identifier of the target file.
[0052] In some embodiments, the browser transmits the upload task to the plug-in, including: the browser requests the server to create an upload task for the target file, and after receiving a response from the server indicating that the upload task has been successfully created, transmits the upload task of the target file to the plug-in. In this manner, after determining that the server has successfully created the upload task, the browser transmits the upload task to the plug-in, thereby ensuring that the plug-in can effectively execute the upload task.
[0053] In some embodiments, before the browser generates an upload task for the target file, the method further includes: the plug-in establishes a WebSocket connection with the browser. The browser and the plug-in are connected via the WebSocket protocol, so that the browser can implement the upload function through the plug-in to enhance the browser's large file upload capability.
[0054] It should be noted that only the WebSocket connection is used as an example here. Other connection methods that can establish two-way communication between the plug-in and the browser are also included and will not be listed here one by one.
[0055] In some embodiments, the browser obtains the unique identifier of the target file that needs to be uploaded to the server by the plug-in, including: when the browser detects an upload file selection operation, the browser transmits an upload file selection instruction to the plug-in; the plug-in pops up a file selection window according to the upload file selection instruction, obtains the selected target file through the file selection window, or obtains the selected folder, and uses all files in the folder as target files; the plug-in returns the unique identifier of the target file to the browser.
[0056] It should be noted that after selecting the target file, the plug-in directly reads the selected file from the hard disk, which improves efficiency. In addition, the plug-in not only supports direct file selection, but also supports folder selection, making file selection simple and convenient. It can select at least two files at a time for uploading without causing browser lag.
[0057] In some embodiments, the browser generates an upload task for a target file, including:
[0058] The browser obtains file upload information saved by the server, wherein the file upload information includes an absolute address of the file, upload progress information of the file, and a client identifier corresponding to the file; the browser determines the file that has not been completely uploaded by the client based on the upload progress information saved by the server; determines a unique identifier of the target file based on the absolute address of the file that has not been completely uploaded and the client identifier corresponding to the file that has not been completely uploaded, and determines resume transfer information of the target file based on the upload progress information of the file that has not been completely uploaded; and the browser generates an upload task for the target file based on the unique identifier and resume transfer information of the target file.
[0059] In an exemplary embodiment, the file that is not completely uploaded is used as the target file, and the upload progress information of the file that is not completely uploaded is used as the resumed transmission information of the target file.
[0060] In the case of breakpoint resuming, this method can automatically identify the file that needs to be resumed, without the need to manually select the same file, which improves the efficiency of file resuming and improves the user experience. In addition, through the absolute address of the target file and the client identifier, the unique identifier of the target file can be determined, so that the target file that needs to be continued to be uploaded and the client that uploaded the target file can be determined through the unique identifier, so that a unique upload task can be generated, ensuring the accuracy and uniqueness of the automatically generated upload task.
[0061] In an exemplary embodiment, the resume information includes a file offset, and the file offset is used to determine a resume starting point of a file resume process.
[0062] In some embodiments, the unique identifier of the incompletely uploaded file is generated based on the absolute address of the incompletely uploaded file and the client identifier corresponding to the incompletely uploaded file, and the client identifier is generated based on the physical address of the device where the client is located. Exemplarily, the combination of the absolute address of the target file and the client identifier is directly used as the unique identifier of the target file. Here, the unique identifier of the file is generated based on the absolute address of the file and the physical address of the device where the client is located, which improves the generation efficiency of the unique identifier of the file, thereby improving the upload efficiency.
[0063] In an exemplary embodiment, before uploading a file, the client is initialized. During the initialization process, it is determined whether the plug-in is installed. If the plug-in has been installed, it is further determined whether the plug-in can run normally and whether the plug-in can communicate with the browser and the server. If the plug-in can run normally and can communicate with the browser and the server respectively, it is determined that the client initialization is successful.
[0064] If the plug-in is not installed, the download address of the plug-in will be prompted and the installation will be prompted.
[0065] When the plug-in is successfully installed and a communication connection is established with the browser, a unique identifier of the plug-in is generated based on information of the device running the plug-in, for example, based on the MAC address of the device running the plug-in.
[0066] The upload progress information may be the ratio of the uploaded file data to the entire file data, or may be an abnormal mark in the case of abnormal upload and the current file offset.
[0067] Step 302: The plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file. A first communication connection is established between the plug-in and the server.
[0068] It should be noted that the specific method of the first communication connection between the plug-in and the server is not limited in the embodiments of the present disclosure. It is only necessary to ensure that the first communication connection can satisfy the plug-in uploading files or file segments to the server.
[0069] In the case that the upload task includes the file identifier of the target file, the plug-in reads the target file from the local based on the file identifier of the target file in the upload task, and uploads the target file to the server through the first communication connection.
[0070] When the upload task includes the file identification and resume information of the target file, the plug-in determines the resume starting point of the target file based on the file identification and resume information of the target file in the upload task, reads the part of the target file that needs to be resumed from the local, and uploads the target file to the server through the first communication connection.
[0071] In some embodiments, a second communication connection is established between the browser and the server; the plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file, including: when the second communication connection is disconnected, the plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file.
[0072] Regardless of whether the second communication connection between the browser and the server is disconnected, the plug-in can upload the target file to the server and save the upload progress information of the target file based on the upload task and the first communication connection, so that the file upload process does not need to depend on the status of the browser.
[0073] In some embodiments, a third communication connection is established between the browser and the plug-in; the plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file, including: when the third communication connection is disconnected, the plug-in continues to upload the target file to the server based on the upload task and the first communication connection, and obtains and saves the upload progress information of the target file.
[0074] Regardless of whether the third communication connection between the plug-in and the browser is disconnected, the plug-in can upload the target file to the server and save the upload progress information of the target file based on the upload task and the first communication connection, so that the file upload process does not need to depend on the status of the browser.
[0075] Among them, the plug-in uploads the target file to the server based on the upload task and the first communication connection, which is independent of the status of the browser. Even if the browser is closed, the plug-in will continue to upload the target file to the server according to the upload task. This makes the file upload process not strongly dependent on the browser. Even if the browser is closed, the file is still uploaded. Subsequently, when the browser is operating normally, the plug-in and the browser can synchronize information such as the file upload progress and the status of whether the upload is completed in a timely manner.
[0076] In some embodiments, the plug-in uploads the target file to the server based on the upload task and the first communication connection, including: the plug-in obtains the target file according to the unique identifier of the target file in the upload task, segments the target file and persists the segment information to local storage, obtains the file stream according to the segment information and uploads it to the server through the first communication connection.
[0077] By carrying the unique identifier of the target file in the upload task, it is possible to uniquely identify a target file that needs to be uploaded, and by segmenting the target file, it is possible to upload a large file even if the target file is large. The upload is not limited by the size of the target file. In addition, the segment information is persisted to the local storage, so that when the upload is stopped and then uploaded again, it can be continued according to the persistently stored segment information, thus avoiding the problem of being unable to resume uploading due to the loss of segments after the upload is stopped.
[0078] Step 303: the browser obtains the upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server.
[0079] Among them, the plug-in uploads the file, and the browser and the server synchronize the upload progress information, which can reduce the situation where the browser is stuck due to excessive memory usage after selecting a large file. The plug-in saves the upload progress information of the target file locally. Even if the device where the plug-in is located is unexpectedly shut down or disconnected from the network, the file upload progress information can still be retained in the plug-in. After the next client initialization, the saved file upload progress information will be synchronized to the server through the browser, and the file can be directly continued based on the saved upload progress information.
[0080] In some embodiments, a third communication connection is established between the browser and the plug-in; the browser obtains the upload progress information of the target file from the plug-in, including: when the plug-in runs normally, the browser obtains the upload progress information of the target file from the plug-in in real time based on the third communication connection;
[0081] In the case that the plug-in does not run normally, the plug-in is restarted, and the browser obtains the upload progress information of the target file from the plug-in in real time based on the third communication connection.
[0082] Even after the browser is closed, the plug-in can still perform the upload task normally, making the file upload process more stable.
[0083] In some embodiments, a third communication connection is established between the browser and the plug-in; the browser obtains the upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server, including: when the second communication connection is restored from a disconnected state to a connected state, the browser obtains the latest upload progress information of the target file from the plug-in based on the third communication connection, saves the latest upload progress information of the target file, and synchronizes the latest upload progress information of the target file to the server based on the second communication connection.
[0084] When the second communication connection is restored, the browser synchronizes the upload progress information in a timely manner, so that the most accurate upload progress information can be obtained from the plug-in, ensuring the consistency of the upload progress information saved by the plug-in, server, and browser, and also laying the foundation for the browser to promptly discover the interrupted upload files.
[0085] In some embodiments, a third communication connection is established between the plug-in and the browser; the browser obtains the upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server, including: when the third communication connection is restored from a disconnected state to a connected state, the browser obtains the latest upload progress information of the target file from the plug-in based on the third communication connection; compares the latest upload progress information with the upload progress information of the target file saved in the browser history, and when the comparison result is inconsistent, synchronizes the latest upload progress information of the target file to the server, and saves the latest upload progress information to the browser.
[0086] In an exemplary embodiment, after the client is successfully initialized, the browser communicates with the plug-in and determines whether there is any upload progress information retained in the plug-in that has not been synchronized to the browser. If so, the browser obtains the file upload progress information from the plug-in via a WebSocket connection and synchronizes it to the browser.
[0087] In the embodiment provided by the present disclosure, after the plug-in in the client obtains the upload task by interacting with the browser in the client, the target file is uploaded to the server based on the upload task and the first communication connection established between the plug-in and the server. When the plug-in and the server can establish a communication connection normally, the upload process of the target file can be completed through the plug-in without relying on the browser. Even if the browser is disconnected from the server, the upload progress of the target file will not be affected, thereby improving the upload efficiency of the target file. In addition, the browser obtains the upload progress information of the target file from the plug-in and synchronizes the upload progress information of the target file to the server, thereby ensuring the consistency of the upload progress of the target file in the browser and the server, so that the browser can timely know the file upload status, so as to provide it to the user for viewing, and the normal use of the browser will not be affected by the upload of files, including the upload of large files or multiple files.
[0088] In summary, the file upload process provided by the embodiments of the present disclosure is stable, efficient, and convenient, and can realize batch uploading of files and enhance the file upload capability.
[0089] The file uploading process described in the above embodiment is explained below through two specific embodiments.
[0090] In a specific embodiment, Figure 4 The following is an example of the process of a client uploading a file. The file uploading process mainly includes:
[0091] Step 501, initializing the client;
[0092] Step 502, the browser in the client determines whether the plug-in is installed, the plug-in is running normally and connected to the browser and the server, if not, execute step 503, if yes, execute step 506;
[0093] Step 503, the browser pops up a window to prompt the running program to prompt the plug-in download address;
[0094] Step 504, the browser installs the plug-in and generates a unique identifier of the plug-in according to the physical address of the device;
[0095] Step 505: The plug-in is successfully installed and establishes communication with the browser via WebSocket;
[0096] Step 506: The client is successfully initialized, and steps 507, 519, and 520 are executed in parallel or separately;
[0097] Step 507: After the browser obtains the instruction to click to select a file to upload, the plug-in pops up a file selection window, and the plug-in selects a file or folder through the pop-up window to obtain the target file to be uploaded;
[0098] Step 508, the plug-in parses the target file information and transmits it to the browser, including the absolute address of the target file, etc.;
[0099] Step 509: The browser receives the target file information and requests the server to create an upload task. The browser receives the information returned by the server indicating that the upload task has been successfully created, and sends the upload task to the plug-in.
[0100] Step 510: The plug-in receives the upload task and starts uploading and synchronizes the upload progress information to the browser in real time. Before or during the upload, the target file is segmented and the segment information is persisted locally.
[0101] Step 511, the plug-in determines whether the plug-in runs normally, if so, executes step 512, otherwise, returns to execute step 501 to reinitialize the client;
[0102] Step 512, the plug-in transmits the file stream of the target file to the server;
[0103] Step 513, the plug-in determines whether the connection between the plug-in and the browser is normal, if yes, execute step 514, otherwise, execute step 518;
[0104] Step 514, the browser receives the file upload progress information of the plug-in and synchronizes it to the server;
[0105] Step 515, the server updates the upload progress information;
[0106] Step 516, the browser determines whether the upload task is abnormal, if not, execute step 517, if yes, execute step 521;
[0107] Step 517, the plug-in determines whether the upload task is completed. If so, the upload is completed and the process ends; otherwise, the process returns to step 514;
[0108] Step 518, the plug-in independently uploads the target file to the server and retains the upload progress information, and then proceeds to step 519;
[0109] Step 519, the browser communicates with the plug-in and determines whether there is relevant upload progress information in the plug-in that has not been synchronized to the browser, and if there is file progress information that has not been synchronized, the plug-in synchronizes the file upload progress information to the browser via WebSocket, and then goes to step 514;
[0110] Step 520, the browser compares the file upload information of the plug-in with the file upload information of the server, and determines whether there is an abnormal unfinished upload task in the server that belongs to the device where the current plug-in is located;
[0111] Step 521 , when the browser determines that there is an abnormality and the upload task is not completed, it queries the server for information such as the file and offset, and then proceeds to execute step 509 .
[0112] Among them, step 511 of determining whether the plug-in is running normally can be performed before or after any step after the client is successfully initialized, and is not limited to Figure 4 For example, the execution order of step 511 and step 512 is swapped, which does not affect the overall file upload effect.
[0113] In this specific embodiment, by designing the interaction process between the browser, the plug-in and the server, the browser can guide the download and installation of the plug-in, and the browser can dominate the generation process of the upload task and instruct the plug-in to execute the upload task, so that the browser assigns the upload task to the plug-in, and the plug-in uploads the file, thereby avoiding the problem of file uploading being too dependent on the browser.
[0114] In another specific embodiment, Figure 5 The following is an example of the process of a client uploading a file. The file uploading process mainly includes:
[0115] Step 601 to step 605 are the same as step 501 and step 505;
[0116] Step 606: The client is successfully initialized, and steps 607, 623, and 621 are executed in parallel or separately;
[0117] Step 607 to step 610 are the same as step 507 to step 510;
[0118] Step 611, the plug-in generates a file stream based on the allocation of the target file and uploads it to the server;
[0119] Step 612, the plug-in determines whether the connection between the plug-in and the browser is normal, if yes, execute step 613, otherwise, execute step 624;
[0120] Step 613, the browser receives the upload progress information of the plug-in and performs logic processing, the main task of the logic processing is to find the unsynchronized upload progress information;
[0121] Step 614, the browser synchronously uploads the progress information to the server in real time;
[0122] Step 615, the browser determines whether the upload task is abnormal, if not, executes step 616, if yes, returns to execute step 617;
[0123] Step 616, the browser determines whether the upload is completed, if so, the upload is completed and the receiving process is performed, if not, step 613 is executed;
[0124] Step 617, the browser synchronously uploads the abnormal information to the server;
[0125] Step 618, the browser queries the server for information such as the file and offset;
[0126] Step 619, the browser uses the absolute storage path of the file and the unique identifier of the plug-in as the unique identifier of the file, which is used to replace the method of using the MD5 value of the file as the unique identifier of the file in the prior art;
[0127] Step 620: The browser directly sends a resume task to the plug-in according to the information obtained from the server, and then goes to step 610;
[0128] Step 621 is the same as step 520;
[0129] Step 622: If the upload task is abnormally not completed, the browser queries the server for information such as the file and the offset, and then proceeds to step 618;
[0130] Step 623, the browser communicates with the plug-in and determines whether there is relevant upload progress information in the plug-in that has not been synchronized to the browser, and if there is file upload progress information that has not been synchronized, the plug-in synchronizes the file upload progress information to the browser through WebSocket, and then goes to step 613;
[0131] Step 624, the plug-in continues to upload the file and saves the file upload progress information locally, waits for the next connection with the browser to synchronize the upload information, and then goes to execute step 623.
[0132] In this specific embodiment, by designing a process for automatically resuming uploads when an upload task is abnormal, the processing process of abnormal uploads is simplified. There is no need to manually select abnormal files that are not fully synchronized, and the client can automatically complete the process of resuming uploads when an upload task is abnormal.
[0133] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0134] In addition, the present disclosure also provides a client, an electronic device, a computer-readable storage medium and a program product, all of which can be used to implement any file uploading method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to in the corresponding records of the method part and will not be repeated here.
[0135] Figure 6 FIG. 1 is a logic block diagram of a client provided by an embodiment of the present disclosure. Figure 6 , the embodiment of the present disclosure provides a client, which includes a plug-in 901 and a browser 902:
[0136] The browser 902 is used to generate an upload task for a target file, transmit the upload task to the plug-in; and obtain upload progress information of the target file from the plug-in, save the upload progress information and synchronize the upload progress information to the server;
[0137] The plug-in 901 is used to upload the target file to the server based on the upload task and the first communication connection, and save the upload progress information of the target file. The first communication connection is established between the plug-in and the server.
[0138] Figure 7 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0139] Reference Figure 7An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 1001; at least one memory 1002, and one or more I / O interfaces 1003, connected between the processor 1001 and the memory 1002; wherein the memory 1002 stores one or more computer programs that can be executed by the at least one processor 1001, and the one or more computer programs are executed by the at least one processor 1001, so that the at least one processor 1001 can execute the above-mentioned file upload method.
[0140] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned file upload method when executed by a processor / processing core. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0141] The embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned file uploading method.
[0142] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0143] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0144] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0145] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0146] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0147] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0148] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0149] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0150] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0151] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A file uploading method, characterized in that: Applied to a client, the client running a plug-in and a browser, the method comprises: The browser generates an upload task for the target file and transmits the upload task to the plug-in; The plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file, and the first communication connection is established between the plug-in and the server; The browser obtains the upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server.
2. The file uploading method according to claim 1, characterized in that: A second communication connection is established between the browser and the server; the plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file, including: When the second communication connection is disconnected, the plug-in uploads the target file to the server based on the upload task and the first communication connection, and saves the upload progress information of the target file.
3. The file uploading method according to claim 2, characterized in that: A third communication connection is established between the browser and the plug-in; the browser obtains upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server, including: When the second communication connection is restored from a disconnected state to a connected state, the browser obtains the latest upload progress information of the target file from the plug-in based on the third communication connection, and saves the latest upload progress information of the target file; The latest upload progress information of the target file is synchronized to the server based on the second communication connection.
4. The file uploading method according to claim 2, characterized in that: A third communication connection is established between the plug-in and the browser; the browser obtains upload progress information of the target file from the plug-in, saves the upload progress information and synchronizes the upload progress information to the server, including: When the third communication connection is restored from a disconnected state to a connected state, the browser obtains the latest upload progress information of the target file from the plug-in based on the third communication connection; Compare the latest upload progress information with the upload progress information of the target file saved in the browser history; When the comparison result is inconsistent, the latest upload progress information of the target file is synchronized to the server, and the latest upload progress information is saved to the browser.
5. The file uploading method according to claim 1, characterized in that: The browser generates a target file upload task, including: The browser obtains the file upload information saved by the server, wherein the file upload information includes the absolute address of the file, the upload progress information of the file, and the client identifier corresponding to the file; Determining the files that have not been completely uploaded by the client based on the upload progress information of the files stored in the server; Determine the unique identifier of the target file based on the absolute address of the incompletely uploaded file and the client identifier corresponding to the incompletely uploaded file, and determine the resumed transmission information of the target file according to the upload progress information of the incompletely uploaded file; Based on the unique identifier of the target file and the resumed transfer information, an upload task for the target file is generated.
6. The file uploading method according to claim 5, characterized in that: The client identifier is generated according to the physical address of the client.
7. The file uploading method according to claim 1, characterized in that: A third communication connection is established between the browser and the plug-in; the browser obtains upload progress information of the target file from the plug-in, including: When the plug-in runs normally, the browser obtains the upload progress information of the target file from the plug-in in real time based on the third communication connection; In the case where the plug-in runs abnormally, the plug-in is restarted, and the browser obtains the upload progress information of the target file from the plug-in in real time based on the third communication connection.
8. A client, characterized in that: Including plugins and browsers; The browser is used to generate an upload task for a target file, transmit the upload task to the plug-in; and obtain upload progress information of the target file from the plug-in, save the upload progress information and synchronize the upload progress information to the server; The plug-in is used to upload the target file to the server based on the upload task and the first communication connection, and save the upload progress information of the target file. The first communication connection is established between the plug-in and the server.
9. An electronic device, characterized in that: include: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor so that the at least one processor can execute the file uploading method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the file uploading method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The invention comprises a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the file uploading method as described in any one of claims 1 to 7.
