Method, system and equipment for supporting uploading of large files in multiple formats and medium
By building functional modules including shard components, browser-compatible components and file upload components, different browsers solve the problem of different file upload processing differences, and achieve stable and efficient file upload in multiple browser environments, significantly improving development efficiency and upload speed.
Patent Information
- Application Number
- CN202411593947.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When developing large file upload functions, due to the differences in processing mechanisms for file uploads by different browsers, developers need to invest a lot of time and energy to ensure the stability of the upload function and the consistency of user experience on all browsers, which seriously affects development efficiency.
By building functional modules that include shard components, browser-compatible components and file upload components, the function of dealing with the differences in file upload processing in different browsers is realized. The specific steps include: dividing the large file into multiple shards, dynamically adjusting the shard size according to the operating environment; detecting the browser's supported functions and converting the shard format into a format supported by the browser; using parallel upload technology to upload the converted shards to the browser.
Through the automatic detection and adaptation functions of browser-compatible components, the workload of developers to perform compatibility testing and adjustments for different browsers is significantly reduced, development time and resources are saved, and development efficiency and file upload efficiency are improved. Parallel upload technology has significantly improved upload speed.
Smart Images

Figure CN119728666A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of file uploading, and more specifically relates to a method, system, device and medium for supporting uploading of large files in multiple formats. Background Art
[0002] With the development of Internet technology, uploading large files is a common requirement of users in daily development. However, the file formats are diverse. Not only are there many types of files, including documents (such as PDF, Word, Excel), pictures (JPEG, PNG, GIF, RAW), audio (MP3, WAV) and other formats, but they may also bring additional compatibility issues due to the different devices, operating systems and browsers used by users.
[0003] When developing large file upload functions, due to the differences in the file upload processing mechanisms of different browsers, such as differences in file type recognition, developers often need to invest a lot of time and energy in different browsers to ensure the stability of the upload function and the consistency of user experience on all browsers, which seriously affects development efficiency. Summary of the invention
[0004] In view of the above problems, the purpose of the present invention is to provide a method, system, device and medium that supports uploading large files in multiple formats, uploading various types of files in the form of components, reducing development time costs, and improving development efficiency and file uploading efficiency.
[0005] In order to achieve the above object, the present invention is implemented through the following technical solutions: In a first aspect, an embodiment of the present application provides a method for supporting uploading large files in multiple formats, including: Build functional components and write a large file upload program, the functional components include a sharding component, a browser compatibility component and a file upload component; Execute the large file upload program, call the sharding component to split the large file into multiple shards based on the large file format, and dynamically adjust the shard size according to the operating environment; The browser compatibility component is called to detect the browser support function. If the browser support function meets the requirements, the format of each fragment is converted into a format file supported by the browser; The file upload component is called to upload multiple segments after format conversion to the browser using parallel upload technology.
[0006] In an optional implementation, calling the fragmentation component to split the large file into multiple fragments based on the large file format specifically includes: Create a file input element to allow users to select a file to upload; Add an event listener to the file input element, which triggers the file upload event when the file input element is used to select the file to be uploaded; When a file upload event is triggered, the shard size is dynamically adjusted according to the operating environment; Use the file interface to read the file to be uploaded; Calculate the number of shards based on the shard size and the size of the file to be uploaded; Call a fragmentation algorithm that is suitable for the format of the file to be uploaded to split the file to be uploaded into the number of fragments; Store each shard in memory.
[0007] In an optional implementation, dynamically adjusting the shard size according to the operating environment specifically includes: Monitor network parameters including bandwidth, latency, and packet loss rate through network monitoring tools; Analyze the current network status based on network indicator parameters, including the degree of congestion; Retrieve the mapping relationship between the preset network status and the shard size; The shard size corresponding to the current network status is determined based on the mapping relationship.
[0008] In an optional implementation, calling a browser compatibility component to detect browser support functions specifically includes: Detect whether the browser has file upload capability available; Detect whether the browser supports two-way communication function; If the browser has a usable file upload function and supports two-way communication, the browser support function meets the requirements.
[0009] In an optional implementation, calling the file upload component to upload the multiple format-converted segments to the browser using a parallel upload technology specifically includes: Retrieve the mapping relationship between the preset network status and the parallel quantity; Determine the parallel quantity corresponding to the current network state according to the mapping relationship; Retrieve several shards from memory and add them to the upload queue; Using parallel technology, multiple shards are obtained from the upload queue in sequence and uploaded to the browser according to the parallel quantity.
[0010] In an optional implementation, a parallel technology is used to sequentially obtain multiple segments from the upload queue according to the parallel quantity before uploading to the browser, specifically including: Create an information object to store the segment ID and segment upload status; Fill the shard ID of each shard into the information object; Initialize the upload status of each shard in the information object.
[0011] In an optional implementation, multiple shards are sequentially obtained from the upload queue and uploaded to the browser according to the parallel quantity, specifically including: Monitor the upload progress of the current shard in real time; If the current segment is uploaded, update the upload status of the current segment in the information object to successfully uploaded; If the current segment fails to be uploaded, the upload status of the current segment is updated in the information object as upload failure; When uploading a segment fails and needs to be re-uploaded, find the last successful segment from the information object and start uploading.
[0012] In a second aspect, the embodiment of the present application further provides a system for supporting uploading large files in multiple formats, including: A component program building module, used to build functional components and write a large file upload program, wherein the functional components include a slicing component, a browser compatibility component and a file upload component; The file sharding module is used to execute the large file upload program, call the sharding component to split the large file into multiple shards based on the large file format, and dynamically adjust the shard size according to the operating environment; The format conversion module is used to call the browser compatibility component to detect the browser support function. If the browser support function meets the requirements, the format of each fragment is converted into a format file supported by the browser; The file upload module is used to call the file upload component to upload multiple segments after format conversion to the browser using parallel upload technology.
[0013] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for supporting uploading large files in multiple formats as described in any one of the above items are implemented.
[0014] In a fourth aspect, an embodiment of the present application further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of supporting uploading of large files in multiple formats as described in any of the above items are implemented.
[0015] It can be seen from the above technical solutions that the present invention has the following advantages: In the method for supporting the upload of large files in multiple formats provided by the present application, by constructing a functional module including a sharding component, a browser compatibility component and a file upload component, the function of coping with the differences in the file upload processing of different browsers is realized. In particular, the browser compatibility component ensures that the upload function can run in multiple browser environments, improving compatibility. At the same time, during the development process, developers no longer need to perform a large amount of compatibility testing and adjustment work for different browsers. The browser compatibility component can automatically detect and adapt to different browser environments, greatly saving development time and resources and improving development efficiency. This application aims at the differences in file type recognition among different browsers, and reduces the upload failure or interruption caused by browser incompatibility through format conversion, thereby improving upload efficiency. This application significantly improves the upload speed by adopting parallel upload technology to upload multiple shards at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0017] Figure 1 A flowchart of a method for supporting uploading large files in multiple formats provided in this application.
[0018] Figure 2 A schematic diagram of the structure of a system that supports uploading large files in multiple formats provided for this application.
[0019] Figure 3 A schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION
[0020] In the specific steps of the method for supporting large file uploads in multiple formats, which will be described in detail below, various embodiments of the present disclosure will be described more fully. The present disclosure may have various embodiments, and adjustments and changes may be made therein. However, it should be understood that there is no intention to limit the various embodiments of the present disclosure to the specific embodiments disclosed herein, but rather the present disclosure should be understood to cover all adjustments, equivalents and / or alternatives that fall within the spirit and scope of the various embodiments of the present disclosure.
[0021] The core of the present invention is to provide a method that supports uploading large files in multiple formats. In related technologies, developers often need to invest a lot of time and energy in different browsers to ensure the stability of the upload function and the consistency of user experience on all browsers, which seriously affects development efficiency.
[0022] The method for supporting the upload of large files in multiple formats provided by the present invention realizes the function of coping with the differences in file upload processing by different browsers by constructing a functional module including a slicing component, a browser compatibility component and a file upload component. In particular, the browser compatibility component ensures that the upload function can run in multiple browser environments, thereby improving compatibility. At the same time, during the development process, developers no longer need to perform a large amount of compatibility testing and adjustment work for different browsers. The browser compatibility component can automatically detect and adapt to different browser environments, thereby greatly saving development time and resources and improving development efficiency.
[0023] Hereinafter, the terms "include" or "may include" used in various embodiments of the present disclosure indicate the presence of disclosed functions, operations, or elements, and do not limit the addition of one or more functions, operations, or elements. In addition, as used in various embodiments of the present disclosure, the terms "include", "have", and their cognates are intended only to indicate specific features, numbers, steps, operations, elements, components, or a combination of the foregoing, and should not be understood as first excluding the presence of one or more other features, numbers, steps, operations, elements, components, or a combination of the foregoing or the possibility of adding one or more features, numbers, steps, operations, elements, components, or a combination of the foregoing.
[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] See also Figure 1 The figure is a flow chart of a method for supporting uploading large files in multiple formats in a specific embodiment, the method comprising: S1, construct functional components and write a large file upload program, wherein the functional components include a sharding component, a browser compatibility component and a file upload component.
[0026] S2, executes the large file upload program, calls the sharding component to split the large file into multiple shards based on the large file format, and dynamically adjusts the shard size according to the operating environment.
[0027] S3, calls the browser compatibility component to detect the browser support function. If the browser support function meets the requirements, the format of each fragment is converted into a format file supported by the browser.
[0028] S4, calling the file upload component to upload multiple segments after format conversion to the browser using parallel upload technology.
[0029] In this embodiment, by constructing a functional module including a slicing component, a browser compatibility component and a file upload component, the function of coping with the differences in file upload processing by different browsers is realized. In particular, the browser compatibility component ensures that the upload function can run in a variety of browser environments, thereby improving compatibility. At the same time, during the development process, developers no longer need to perform a large amount of compatibility testing and adjustment work for different browsers. The browser compatibility component can automatically detect and adapt to different browser environments, greatly saving development time and resources and improving development efficiency. In view of the differences in file type recognition by different browsers, format conversion is used to reduce upload failures or interruptions caused by browser incompatibility, thereby improving upload efficiency. By adopting parallel upload technology, multiple slicing can be uploaded at the same time, significantly improving upload speed.
[0030] In an embodiment of the present invention, based on step S1, a possible embodiment is given below to illustrate its specific implementation scheme in a non-limiting manner.
[0031] S101: Build functional components.
[0032] Functional components include sharding components, browser compatibility components, and file upload components. The sharding component is used to split large files into multiple shards based on the large file format, and dynamically adjust the size of the shards according to the operating environment. The browser compatibility component is used to detect browser support functions. If the browser support function meets the requirements, the format of each shard is converted into a format file supported by the browser. The file upload component is used to upload multiple shards after format conversion to the browser using parallel upload technology. Functional components expose APIs to achieve high scalability and customization, improving work efficiency in terms of time cost and labor cost.
[0033] S102: Write a large file upload program.
[0034] According to the upload logic, write a large file upload program to call each functional component in sequence to realize the multi-part upload of large files.
[0035] In an embodiment of the present invention, based on step S2, a possible embodiment is given below to illustrate its specific implementation scheme in a non-limiting manner.
[0036] S201: Create a file input element to allow the user to select a file to be uploaded.
[0037] As an example, create a <input> An element with its type attribute set to file to allow the user to select a file.
[0038] S202: Add an event listener to the file input element, and trigger a file upload event when the file input element is used to select a file to be uploaded.
[0039] As an example, use JavaScript to add a change event listener to the file input element. When the user selects a file, the event will be triggered.
[0040] S203: When a file upload event is triggered, dynamically adjust the shard size according to the operating environment.
[0041] As an example, the size of each segment is determined (e.g., 1 MB per segment). This can be set dynamically based on the file size and network conditions.
[0042] Dynamically adjust the shard size according to the operating environment, as follows: Step 1: Monitor network parameters including bandwidth, latency, and packet loss rate using network monitoring tools. Step 2: Analyze the current network status, including the degree of congestion, based on network indicator parameters; Step 3, retrieve the mapping relationship between the preset network status and the shard size; Step 4: Determine the shard size corresponding to the current network status according to the mapping relationship.
[0043] It should be noted that the mapping relationship between the network status and the slice size is pre-configured. The network status includes the congestion degree, which can be configured in a graded manner. If the congestion degree is low, a larger slice size is adapted, otherwise a smaller slice size is adapted.
[0044] S204: Using the file interface to read the file to be uploaded.
[0045] As an example, get the file object selected by the user through the File API and use the FileReader or Blob.slice() method to read the file content.
[0046] S205: Calculate the number of segments according to the segment size and the size of the file to be uploaded.
[0047] S206: Invoke a segmentation algorithm adapted to the format of the file to be uploaded to segment the file to be uploaded into segments of the number of segments.
[0048] It should be noted that different fragmentation algorithms are pre-configured for files of different formats. For example, for text files, the fragmentation algorithm can be directly split by line or by byte when fragmenting. For image files, the fragmentation algorithm is processed according to the image format (such as JPEG, PNG, etc.) and encoding method.
[0049] S207: Store each shard in memory.
[0050] As an example, use an array to store each slice in memory, or you can store it in a temporary file.
[0051] In an embodiment of the present invention, based on step S3, a possible embodiment is given below to illustrate its specific implementation scheme in a non-limiting manner.
[0052] S301: Detect browser support functions.
[0053] In this embodiment, detecting the browser support functions includes detecting whether the browser has an available file upload function and detecting whether the browser supports a two-way communication function. If the browser has an available file upload function and supports two-way communication, the browser support functions meet the requirements.
[0054] As examples, the functions of HTML5 File API, XMLHttpRequest 2, and WebSocket are tested.
[0055] Detect HTML5 File API support: Use window.File and window.FileReader to detect File API support. If these objects exist, the File API is supported.
[0056] Detect XMLHttpRequest 2 support: Check if an XMLHttpRequest object exists and try to use its upload property to detect if progress events are supported.
[0057] Detect WebSocket support: Use window.WebSocket to detect WebSocket support. If the WebSocket object exists, WebSocket is supported.
[0058] S302: Convert the formats of each segment into a format file supported by the browser.
[0059] It should be noted that before uploading the file, the component pre-processes the file, converts and encodes the file format to ensure the compatibility of the file in different browsers.
[0060] In an embodiment of the present invention, based on step S4, a possible embodiment is given below to illustrate its specific implementation scheme in a non-limiting manner.
[0061] S401: Retrieve a preset mapping relationship between a network state and a parallel quantity.
[0062] It should be noted that the mapping relationship between the network status and the parallel number is pre-configured. The network status includes the congestion degree, which can be configured in a graded manner. If the congestion degree is low, a larger parallel number is adapted, otherwise a smaller parallel number is adapted.
[0063] S402: Determine the parallel quantity corresponding to the current network state according to the mapping relationship.
[0064] S403: Retrieve several shards from the memory and add them to the upload queue.
[0065] S404: adopting parallel technology, obtaining multiple segments from the upload queue in sequence according to the parallel quantity and uploading them to the browser.
[0066] When uploading each slice, the component creates an object in the foreground to store the uploaded slices and the upload status, including the uploaded slices and the unuploaded slices. The specific steps include: Step 1: Create an information object to store the segment ID and segment upload status; Step 2, fill the fragment ID of each fragment into the information object; Step 3: Initialize the upload status of each fragment in the information object.
[0067] It should be noted that a unique identifier (such as a file name and a segment index) is created for each segment in advance, and they are added to a queue waiting for upload, so as to facilitate the detection of the upload status of each segment. Exemplarily, the upload status of each segment is initialized to not uploaded.
[0068] As an example, multiple shards are obtained from the upload queue in sequence according to the parallel quantity and uploaded to the browser, specifically including: S404.1, monitor the upload progress of the current segment in real time.
[0069] S404.2: If the current segment is uploaded, the upload status of the current segment is updated in the information object as successfully uploaded.
[0070] S404.3: If the current segment fails to be uploaded, the upload status of the current segment is updated in the information object as upload failure.
[0071] S404.4: When uploading a segment fails and needs to be re-uploaded, the last successful segment is found from the information object and the upload begins.
[0072] As an example, upload segments to the server sequentially or concurrently. You can use XMLHttpRequest, fetchAPI, or a third-party library (such as Axios) to send requests. Listen for upload progress events, update the upload progress bar, or provide other user feedback. Check the upload results of each segment, handle any errors, and retry the failed upload segments as needed. For example, when the upload process is interrupted, the component saves the current upload progress, traverses the sliced files, and finds the last successfully uploaded segment to continue uploading based on the upload content information returned by the upload interface, instead of starting over. When all segments are successfully uploaded, notify the user that the upload is complete, and may perform some subsequent operations.
[0073] like Figure 2 As shown, the following is an embodiment of a system for supporting uploading large files in multiple formats provided by an embodiment of the present disclosure. The system and the method for supporting uploading large files in multiple formats in the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiment of the system for supporting uploading large files in multiple formats, reference can be made to the embodiment of the method for supporting uploading large files in multiple formats.
[0074] A system supporting uploading of large files in various formats includes: a component program building module, a file segmentation module, a format conversion module, and a file uploading module.
[0075] A component program building module, used to build functional components and write a large file upload program, wherein the functional components include a slicing component, a browser compatibility component and a file upload component; The file sharding module is used to execute the large file upload program, call the sharding component to split the large file into multiple shards based on the large file format, and dynamically adjust the shard size according to the operating environment; The format conversion module is used to call the browser compatibility component to detect the browser support function. If the browser support function meets the requirements, the format of each fragment is converted into a format file supported by the browser; The file upload module is used to call the file upload component to upload multiple segments after format conversion to the browser using parallel upload technology.
[0076] The system provided in this embodiment supports uploading large files in multiple formats. By constructing a functional module including a sharding component, a browser compatibility component, and a file upload component, the function of coping with the differences in file upload processing by different browsers is realized. In particular, the browser compatibility component ensures that the upload function can run in multiple browser environments, thereby improving compatibility. At the same time, during the development process, developers no longer need to perform a large amount of compatibility testing and adjustment work for different browsers. The browser compatibility component can automatically detect and adapt to different browser environments, greatly saving development time and resources and improving development efficiency. In view of the differences in file type recognition by different browsers, format conversion is used to reduce upload failures or interruptions caused by browser incompatibility, thereby improving upload efficiency. By adopting parallel upload technology, multiple shards can be uploaded at the same time, significantly improving upload speed.
[0077] Figure 3 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0078] The method for supporting uploading of large files in multiple formats provided in the embodiment of the present application can be applied to electronic devices. It will be appreciated by those skilled in the art that the electronic device structure involved in the embodiment of the present invention does not constitute a limitation on the electronic device, and the electronic device may include more or less components than shown, or combine certain components, or arrange different components. In an embodiment of the present invention, the electronic device includes but is not limited to a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples, and are not intended to limit the implementation of the embodiments of the present application described herein and / or required.
[0079] The electronic device may include a processor, an external memory interface, an internal memory, a universal serial bus (USB) interface, a charging management module, a power management module, a battery, a wireless communication module, an audio module, a speaker, a microphone, a sensor module, buttons, a camera, a display, and a SIM card interface, etc.
[0080] The processor may include one or more processing units, for example, the processor may include a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors.
[0081] The processor can be the nerve center and command center of the electronic device. The controller can generate an operation control signal according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0082] A memory may also be provided in the processor for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. The memory may store instructions or data that the processor has just used or is cyclically used. If the processor needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor, and thus improves system efficiency.
[0083] The external memory interface can be used to connect an external memory card, such as a MicroSD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor through the external memory interface to implement data storage functions. For example, files such as music and videos can be saved in the external memory card.
[0084] The internal memory can be used to store computer executable program codes, which include instructions. The processor executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory. The internal memory may include a program storage area and a data storage area. The internal memory may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0085] The wireless communication function of an electronic device can be realized through an antenna, a wireless communication module, a modem processor, and a baseband processor.
[0086] The wireless communication module can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc.
[0087] Electronic devices can implement audio functions, etc. through audio modules, speakers, receivers, microphones, headphone jacks, and application processors.
[0088] Electronic devices can achieve shooting functions through ISP, camera, video codec, GPU, display and application processor.
[0089] Electronic devices can achieve display functions through GPU, display screen and application processor.
[0090] The GPU is a microprocessor for image processing that connects the display screen and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor may include one or more GPUs that execute program instructions to generate or change display information.
[0091] The display screen is used to display images, videos, etc. The display screen includes a display panel.
[0092] The above-mentioned electronic device implements the method of the present application for supporting the uploading of large files in multiple formats by constructing a functional module including a slicing component, a browser compatibility component and a file upload component, thereby realizing the function of coping with the differences in file upload processing by different browsers. In particular, the browser compatibility component ensures that the upload function can run in multiple browser environments, thereby improving compatibility. At the same time, during the development process, developers no longer need to perform a large amount of compatibility testing and adjustment work for different browsers. The browser compatibility component can automatically detect and adapt to different browser environments, thereby greatly saving development time and resources and improving development efficiency.
[0093] The storage medium provided in the present application stores a program product that can implement a method for supporting uploading large files in multiple formats.
[0094] The method for supporting the upload of large files in multiple formats includes: S1, constructing functional components and writing a large file upload program, wherein the functional components include a slicing component, a browser compatibility component and a file upload component. S2, executing the large file upload program, calling the slicing component to split the large file into multiple slices based on the large file format, and dynamically adjusting the slice size according to the operating environment. S3, calling the browser compatibility component to detect the browser support function, if the browser support function meets the requirements, then converting the format of each slice into a format file supported by the browser. S4, calling the file upload component to use parallel upload technology to upload the multiple slices after format conversion to the browser.
[0095] In some possible implementations, the method of supporting uploading large files in multiple formats disclosed herein can be implemented in the form of a program product, which includes program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps described in the above “Exemplary Method” section of this specification according to various exemplary implementations of the present disclosure.
[0096] The storage medium of the present disclosure can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0097] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be 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 invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for supporting uploading large files in multiple formats, characterized in that: include: Build functional components and write a large file upload program, the functional components include a sharding component, a browser compatibility component and a file upload component; Execute the large file upload program, call the sharding component to split the large file into multiple shards based on the large file format, and dynamically adjust the shard size according to the operating environment; The browser compatibility component is called to detect the browser support function. If the browser support function meets the requirements, the format of each fragment is converted into a format file supported by the browser; The file upload component is called to upload multiple segments after format conversion to the browser using parallel upload technology.
2. The method for supporting uploading large files in multiple formats according to claim 1, characterized in that: Calling the sharding component will split the large file into multiple shards based on the large file format, including: Create a file input element to allow users to select a file to upload; Add an event listener to the file input element, which triggers the file upload event when the file input element is used to select the file to be uploaded; When a file upload event is triggered, the shard size is dynamically adjusted according to the operating environment; Use the file interface to read the file to be uploaded; Calculate the number of shards based on the shard size and the size of the file to be uploaded; Call a fragmentation algorithm that is suitable for the format of the file to be uploaded to split the file to be uploaded into the number of fragments; Store each shard in memory.
3. The method for supporting uploading large files in multiple formats according to claim 2, characterized in that: Dynamically adjust the shard size based on the operating environment, including: Monitor network parameters including bandwidth, latency, and packet loss rate through network monitoring tools; Analyze the current network status based on network indicator parameters, including the degree of congestion; Retrieve the mapping relationship between the preset network status and the shard size; The shard size corresponding to the current network status is determined based on the mapping relationship.
4. The method for supporting uploading large files in multiple formats according to claim 3, characterized in that: Call the browser compatibility component to detect browser support functions, including: Detect whether the browser has available file upload capabilities; Detect whether the browser supports two-way communication function; If the browser has a usable file upload function and supports two-way communication, the browser support function meets the requirements.
5. The method for supporting uploading large files in multiple formats according to claim 4, characterized in that: Call the file upload component to upload multiple segments after format conversion to the browser using parallel upload technology, including: Retrieve the mapping relationship between the preset network status and the parallel quantity; Determine the parallel quantity corresponding to the current network state according to the mapping relationship; Retrieve several shards from memory and add them to the upload queue; Using parallel technology, multiple shards are obtained from the upload queue in sequence and uploaded to the browser according to the parallel quantity.
6. The method for supporting uploading large files in multiple formats according to claim 5, characterized in that: Using parallel technology, multiple shards are obtained from the upload queue in sequence according to the parallel quantity before being uploaded to the browser, specifically including: Create an information object to store the segment ID and segment upload status; Fill the shard ID of each shard into the information object; Initialize the upload status of each shard in the information object.
7. The method for supporting uploading of large files in multiple formats according to claim 6, characterized in that: According to the number of parallel operations, multiple shards are obtained from the upload queue and uploaded to the browser in sequence, including: Monitor the upload progress of the current shard in real time; If the current segment is uploaded, update the upload status of the current segment in the information object to successfully uploaded; If the current segment fails to be uploaded, the upload status of the current segment is updated in the information object as upload failure; When uploading a segment fails and needs to be re-uploaded, find the last successful segment from the information object and start uploading.
8. A system that supports uploading large files in multiple formats, characterized in that: include: A component program building module, used to build functional components and write a large file upload program, wherein the functional components include a slicing component, a browser compatibility component and a file upload component; The file sharding module is used to execute the large file upload program. The sharding component is called to split the large file into multiple shards based on the large file format, and the shard size is dynamically adjusted according to the operating environment; The format conversion module is used to call the browser compatibility component to detect the browser support function. If the browser support function meets the requirements, the format of each fragment is converted into a format file supported by the browser; The file upload module is used to call the file upload component to upload multiple segments after format conversion to the browser using parallel upload technology.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method for supporting uploading large files in multiple formats as described in any one of claims 1 to 7 are implemented.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for supporting uploading large files in multiple formats as claimed in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for uploading file
CN104035989A
File web uploading implementation method, storage medium, electronic equipment and device
CN116938919A
Cited By
Storage method and device of authentication toolkit, electronic equipment and storage medium
CN120354400A
Front-end large file uploading method and device
CN120416239A