File uploading method and device and related equipment
By loading business to realize classes and using file upload status information, the problem of high computing resources consumption during file upload in the existing technology is solved, efficient file generation and uploading is realized, and user experience and system maintenance flexibility is improved.
Patent Information
- Application Number
- CN202411737064.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-29
AI Technical Summary
When handling multiple file types, the existing file upload mechanism needs to consume a lot of computing resources during the file generation and upload stages, and lacks universality, resulting in increased code redundancy and maintenance difficulty.
By loading pre-configured business implementation classes, assemble personalized information according to the file type, and use the file upload status information in the cache to quickly determine whether the file has been uploaded, avoiding repeated generation and upload.
It realizes efficient generation and upload of file uploads, reduces the consumption of computing resources, improves file upload speed, reduces code redundancy and maintenance difficulty, and improves user experience.
Smart Images

Figure CN119544701A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and more specifically, to a file uploading method, device and related equipment. Background Art
[0002] The file upload function is crucial in modern computer applications, especially in Internet business systems. From bank loan business to express logistics systems, various scenarios require uploading files to record and process information.
[0003] As business develops and needs change, the file types, formats, and contents that need to be uploaded also change. Users may upload the same file multiple times, resulting in a waste of storage space and an increase in processing burden. Traditional solutions, such as verification methods based on file hash values (MD5, SHA, etc.), require calculating the hash value of the file and comparing it with existing records in the database, which consumes a lot of computing resources and time, especially when processing large files. In addition, when generating different types of files, traditional solutions require writing specific generation logic for each type, that is, a logic for generating files can only generate one type of file. This lack of universality leads to code redundancy and is difficult to expand and maintain.
[0004] In summary, when dealing with the growing demand for file uploads, the existing file upload mechanism not only calls specific generation logic in the file generation phase, but also consumes a lot of computing resources in the upload phase to determine whether to retransmit. Summary of the invention
[0005] In view of the above problems, this application is proposed to provide a file uploading method, device and related equipment to achieve efficient generation and uploading of files. The specific scheme is as follows:
[0006] In a first aspect, a method for uploading a file is provided, comprising:
[0007] Obtain a file upload request, wherein the file upload request includes a file type;
[0008] Loading pre-configured business implementation classes, each of which corresponds to the file type one by one, and is used to assemble personalized information of the corresponding type of file;
[0009] Traverse each business implementation class one by one. For the currently traversed business implementation class:
[0010] Determine whether the file type corresponding to the currently traversed business implementation class is included in the file upload request. If not, skip the currently traversed business implementation class. If so, obtain the file upload status information configured in the cache. Based on the file upload status information, determine whether the file type corresponding to the currently traversed business implementation class has been uploaded. The file upload status information records the correspondence between different business implementation classes and upload statuses. The upload status corresponding to any business implementation class indicates whether the file type corresponding to the business implementation class has been uploaded.
[0011] If the file of the type corresponding to the currently traversed business implementation class has not been uploaded, obtain the public information of the file to assemble the public information part of the file, use the currently traversed business implementation class to obtain the corresponding personalized data in the cache and assemble the personalized information part of the file, and the public information part and the personalized information part constitute the file;
[0012] Upload said file;
[0013] The file upload status information is updated according to the upload result of the file.
[0014] Preferably, the file upload status information is stored in a one-dimensional structure, which includes a number of data bits, different data bits correspond to different business implementation classes, and the data bits represent different upload states of files of the type corresponding to the corresponding business implementation class by storing different numerical values.
[0015] Preferably, the value stored in the data bit is a first value, a second value or a third value, the first value indicates that the file is uploaded successfully, the second value indicates that the file is not uploaded, and the third value indicates that the file is uploaded unsuccessfully.
[0016] Preferably, judging whether a file of a type corresponding to a currently traversed business implementation class has been uploaded based on the file upload status information includes:
[0017] If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the first value, then the file of the type corresponding to the currently traversed business implementation class has been uploaded;
[0018] If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the second value or the third value, then the file of the type corresponding to the currently traversed business implementation class is not uploaded.
[0019] Preferably, the first value is 0, the second value is 1, and the third value is m, where m is a value greater than 1;
[0020] Correspondingly, updating the file upload status information according to the upload result of the file includes:
[0021] If the file is uploaded successfully, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is updated to 0;
[0022] If the file upload fails, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is increased by 1.
[0023] Preferably, if the value stored in the data bit in the file upload status information is greater than a preset upload threshold, a log indicating the number of times the file has failed to be uploaded is generated according to the value stored in the data bit and output to the user.
[0024] In a second aspect, a file uploading device is provided, comprising:
[0025] A request acquisition unit, used to acquire a file upload request, wherein the file upload request includes a file type;
[0026] A business implementation class loading unit, used to load pre-configured business implementation classes, the business implementation classes correspond to the file types one by one, and are used to assemble personalized information of files of corresponding types;
[0027] The business implementation class traversal unit is used to traverse each business implementation class one by one. For the currently traversed business implementation class:
[0028] Determine whether the file type corresponding to the currently traversed business implementation class is included in the file upload request. If not, skip the currently traversed business implementation class. If so, obtain the file upload status information configured in the cache. Based on the file upload status information, determine whether the file type corresponding to the currently traversed business implementation class has been uploaded. The file upload status information records the correspondence between different business implementation classes and upload statuses. The upload status corresponding to any business implementation class indicates whether the file type corresponding to the business implementation class has been uploaded.
[0029] If the file of the type corresponding to the currently traversed business implementation class has not been uploaded, obtain the public information of the file to assemble the public information part of the file, use the currently traversed business implementation class to obtain the corresponding personalized data in the cache and assemble the personalized information part of the file, and the public information part and the personalized information part constitute the file;
[0030] Upload said file;
[0031] The file upload status information is updated according to the upload result of the file.
[0032] In a third aspect, an electronic device is provided, comprising: a memory and a processor;
[0033] The memory is used to store programs;
[0034] The processor is used to execute the program to implement the various steps of the file uploading method described in any one of the first aspects of the present application.
[0035] In a fourth aspect, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the various steps of the file uploading method described in any one of the first aspects of the present application are implemented.
[0036] By means of the above technical solution, the present application can quickly determine whether a file of a specific type has been uploaded by using the file upload status information configured in the cache during the file generation stage. If it has been uploaded, the subsequent generation and upload steps are directly skipped, avoiding the need to generate the file in the file generation stage and then determine whether the file has been uploaded in the file upload stage, saving computing resources and time. By introducing business implementation classes and public information, the processing logic of the public part and the personalized information part of different types of files are encapsulated separately, realizing the decoupling and modular design of the file generation logic, and because unnecessary calculations and upload operations are reduced, the file upload speed is improved, thereby improving the user experience, especially when uploading large files or in poor network environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0038] Figure 1 A schematic diagram of a process of uploading a file provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of a scenario illustrating a method for uploading a file;
[0040] Figure 3 A schematic diagram of the structure of a file uploading device provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] The embodiment of the present application provides a file uploading method, and the solution of the present application can be applied to a terminal with data processing capabilities, which can be a mobile phone, a computer, a server, etc.
[0044] Next, combine Figure 1 The method for uploading the file specifically comprises the following steps:
[0045] Step S100: Obtain a file upload request, where the file upload request includes a file type.
[0046] Specifically, this step marks the beginning of the file upload process. For example, a web browser, a mobile application, or a dedicated upload tool can be used to send a file upload request to start the file upload. The request can use the HTTP POST method and include the file type. For a specific scenario, the file upload request can include the file types of all files that need to be uploaded in this scenario.
[0047] Step S110: loading pre-configured business implementation classes, wherein the business implementation classes correspond to the file types one by one and are used to assemble personalized information of files of corresponding types.
[0048] Specifically, after receiving a file upload request, a pre-configured business implementation class is loaded. These business implementation classes are specially designed to handle specific types of files. This type-based architecture provides flexibility and scalability. Business implementation classes correspond one-to-one to file types, which means that for each file type, there is a corresponding business implementation class to handle its unique needs. The purpose of these business implementation classes can be to assemble personalized information for files of the corresponding type. For example, a business implementation class of the identity authentication type may add the user's personal information, identification information, etc. The business implementation class can add programming language, code version, and dependency information. Loading these business implementation classes may involve instantiating them and saving them in memory so that they can be accessed quickly.
[0049] Step S120: Determine whether the traversal of the business implementation classes is complete.
[0050] Specifically, the loaded business implementation class set is traversed. The number of business implementation classes is the number of loop judgments, and this traversal process is intended to find a specific business implementation class that matches the file type contained in the file upload request. Each business implementation class is checked one by one, and its associated file type is compared with the file type in the file upload request. This iterative method ensures that the server can identify the correct handler even if multiple file types are supported. The efficiency of the traversal can depend on the specific data structure and search algorithm used. For example, a hash table or dictionary can provide faster lookup time than a linear search.
[0051] Step S130: Determine whether the file type corresponding to the currently traversed business implementation class is included in the file upload request.
[0052] Specifically, the file type corresponding to the currently traversed business implementation class is compared with the file type extracted from the file upload request. If the file types do not match, the current business implementation class is skipped and the next business implementation class is traversed. If a match is found, step S140 is executed.
[0053] Step S140: Obtain the file upload status information configured in the cache.
[0054] Specifically, the file upload status information is retrieved from the cache. The cache, which may be Redis or Memcached, is used to store frequently accessed data to improve performance.
[0055] Step S150: Based on the file upload status information, determine whether a file of the type corresponding to the currently traversed business implementation class has been uploaded.
[0056] Specifically, the file upload status information records the correspondence between different business implementation classes and upload statuses. The upload status corresponding to any business implementation class indicates whether the file of the type corresponding to the business implementation class has been uploaded. This allows tracking the upload progress of each type of file. The file upload status information can indicate whether the file has been uploaded. When the judgment result of step S150 is yes, the currently traversed business implementation class is skipped, otherwise, step S160 is executed.
[0057] Step S160, obtaining the public information of the file to assemble the public information part of the file, using the currently traversed business implementation class to obtain the corresponding personalized data in the cache and assemble the personalized information part of the file, and the file is composed of the public information part and the personalized information part.
[0058] Specifically, if it is determined that the file type corresponding to the currently traversed business implementation class has not been uploaded, the file information will continue to be assembled. This involves obtaining the common information of the file, such as the file name, file size, and content type. In addition, the currently traversed business implementation class is used to obtain the corresponding personalized data in the cache. These personalized data may include data information specific to the file type, and then the common information part and the personalized information part are combined to form a complete file to be uploaded. This combination step can associate all necessary information with the file for correct processing and storage.
[0059] Step S170: Upload the file.
[0060] Specifically, the assembled file is uploaded to a specified storage location. This can be a cloud storage service (such as Amazon S3, Google Cloud Storage), a local file system, or a network shared drive. The upload process may involve various techniques, such as multi-block upload, breakpoint resuming, and checksum verification, to ensure data integrity and efficiency.
[0061] Step S180: Update the file upload status information according to the upload result of the file.
[0062] Specifically, the file upload status information in the cache is updated according to the upload result of the file. If the upload is successful, the status is updated to "Uploaded". If the upload fails, the status is updated to "Upload Failed" and may include an error code or message for further investigation. Updating the status information in the cache ensures that an accurate record of the upload status is maintained, which is critical for tracking progress and handling potential upload failures. This information can also be used to provide feedback to the client, such as an upload progress bar or upload completion notification.
[0063] By using the file upload status information in the cache, the uploaded file type can be quickly identified, thus avoiding repeated generation and uploading, saving resources and time. At the same time, through the encapsulation of business implementation classes and public information, the logical decoupling and modularization of file generation is achieved, the file upload efficiency is improved, and the user experience is optimized, especially when processing large files or poor network conditions.
[0064] The following embodiment introduces the file upload status information in the aforementioned embodiment: the file upload status information is stored in a one-dimensional structure, the one-dimensional structure includes a number of data bits, different data bits correspond to different business implementation classes, and the data bits represent different upload states of files of the type corresponding to the corresponding business implementation class by storing different numerical values.
[0065] Specifically, a one-dimensional structure, such as an array or a bit vector, is a linear data storage method in which each element (data bit) represents a specific business implementation class. This design can quickly access and update the upload status of any specific file type because each business implementation class has a fixed position or index corresponding to it. In a one-dimensional structure, a data bit can be a Boolean value, integer, or enumeration type to represent the upload status of the file, such as not uploaded, uploaded, or upload failed. The specific value of the data bit can be defined according to actual needs to efficiently represent the status information.
[0066] When a file upload request occurs, the corresponding business implementation class is searched according to the file type, and then the corresponding data bit in the one-dimensional structure is located. If the file is not uploaded, the upload process is executed, and the data bit is updated after the upload is successful. If the upload fails, the data bit is updated according to the number of failures, such as increasing the number of failures or setting it to a specific failure code. Before uploading the file, the value of the corresponding data bit in the one-dimensional structure can be checked to determine whether the file needs to be uploaded again. If the data bit already indicates that the file has been successfully uploaded, the upload process is skipped, thereby avoiding unnecessary calculations and network transmissions and improving efficiency.
[0067] The file upload status information stored in a one-dimensional structure can be cached in memory for fast access. This caching mechanism helps reduce the number of accesses to the database or persistent storage, which can significantly improve performance, especially in high-concurrency scenarios.
[0068] The following embodiment introduces the numerical value stored in the data bit of the file upload status information in the aforementioned embodiment: the numerical value stored in the data bit is a first numerical value, a second numerical value or a third numerical value, the first numerical value indicates that the file is uploaded successfully, the second numerical value indicates that the file is not uploaded, and the third numerical value indicates that the file upload fails.
[0069] Accordingly, judging whether a file of a type corresponding to the currently traversed business implementation class has been uploaded based on the file upload status information includes:
[0070] If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the first value, then the file of the type corresponding to the currently traversed business implementation class has been uploaded;
[0071] If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the second value or the third value, then the file of the type corresponding to the currently traversed business implementation class is not uploaded.
[0072] Specifically, the values stored in the data bits are clearly defined as three states: the first value, the second value, and the third value. This definition provides a clear and concise method for representing states, making the identification and processing of states intuitive. The first value can be set to represent the state of successful file upload. The second value represents that the file has not been uploaded, indicating that the upload process for this file type has not yet started. The third value indicates that the file upload failed, and upload failure also means that the file has not been uploaded.
[0073] When a file upload request is initiated, check the value in the data bit of the corresponding business implementation class. If the value of the data bit is the second value or the third value (the file has not been uploaded or the previous upload failed), execute the file generation and upload process. After the upload is successful, the value of the data bit will be updated to the first value (the file upload is successful). If an error occurs during the upload process, the value of the data bit will be updated to the third value (the file upload failed), and an error code or failure reason can be attached to facilitate error tracking and subsequent processing.
[0074] Through this judgment method based on file upload status information, the file upload status of different business implementation classes can be efficiently managed, and fast status query and update can be achieved, while unnecessary calculation and upload operations are reduced, and performance and user experience are optimized.
[0075] The following embodiment further limits the file upload status information in the above embodiment: the first value is 0, the second value is 1, the third value is m, and m is a value greater than 1;
[0076] Correspondingly, updating the file upload status information according to the upload result of the file includes:
[0077] If the file is uploaded successfully, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is updated to 0;
[0078] If the file upload fails, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is increased by 1.
[0079] If the value stored in the data bit in the file upload status information is greater than a preset upload threshold, a log indicating the number of times the file has failed to be uploaded is generated according to the value stored in the data bit and output to the user.
[0080] Specifically, if a file fails to upload, the corresponding data bit value is increased by 1. This design allows tracking the number of failures, and different strategies can be adopted based on the number of failures, such as retrying the upload or notifying the user. By encoding the number of failures in the value of the data bit (i.e., the third value m-1), the history of failed uploads for each file type can be recorded. This helps to identify potential problems in the upload process and provides data support for troubleshooting and optimization. If the m value exceeds the preset upload threshold, a log indicating the number of times the file has failed to upload can be generated and fed back to the user. In addition, for upload operations that take a long time, an asynchronous method can be used, and the status information can be updated asynchronously after the upload is completed.
[0081] Through this design, the management of file upload status information becomes more flexible and efficient, while also improving maintainability and user experience. The status information can be dynamically updated based on the file upload results, and corresponding actions can be taken, such as providing feedback to the user on the number of file upload failures.
[0082] The following embodiment introduces the personalized data in the above embodiment. The personalized data includes:
[0083] The identifier of the business implementation class and the personalized data information of the file of the type corresponding to the business implementation class.
[0084] Specifically, the personalized data stored in the cache contains the identifier of the business implementation class. Each business implementation class has a unique identifier, which can be a class name, ID or enumeration value, which is used to uniquely identify a business implementation class. Personalized data information refers to the file attributes and data content associated with a specific business implementation class. These data can be specially processed during the file generation and upload process. For example, for a business implementation class that processes invoices, personalized data may include invoice number, date, amount and other information; while for a business implementation class that processes contracts, personalized data may include contract terms, signatory information, contract validity period and other information.
[0085] By introducing the business implementation class identifier and the corresponding personalized data information, this method can flexibly provide customized file personalized information generation logic to meet the needs of different business scenarios. Storing personalized data in the cache can improve the speed and efficiency of data processing while ensuring fast access and consistency of data.
[0086] Figure 2 A schematic diagram of a scenario illustrating a method for uploading a file.
[0087] like Figure 2As shown in the figure, a scenario of a file upload method is described. This method supports multiple file types and provides customized processing logic for each type. First, a file upload request is received, which contains the file type information to be uploaded. Then, the pre-configured business implementation classes are loaded, and each business implementation class is responsible for processing a specific file type. These business implementation classes are traversed in turn to find the implementation class that matches the file type in the file upload request.
[0088] After finding a matching business implementation class, check the file upload status information stored in the cache. This status information is stored in a one-dimensional structure, with each data bit corresponding to a business implementation class, and the value of the data bit indicating the upload status of the corresponding file type: 0 indicates successful upload, 1 indicates failure to upload, and a value greater than 1, m, indicates m-1 times of failed upload. If the status information shows that the file has not been uploaded or has failed to upload, the upload process will continue.
[0089] The upload process first assembles file information, including common information and personalized information. Common information refers to information common to all file types, such as file name, file size, etc. Personalized information is generated by the current business implementation class based on the personalized data stored in the cache, which contains the business implementation class identifier and specific data for the corresponding file type.
[0090] After assembling the file information, upload the file to the specified storage location. After the upload is completed, update the file upload status information in the cache according to the upload result. If the upload is successful, update the value of the corresponding data bit to 0; if the upload fails, increase the value of the corresponding data bit by 1. If the value of the data bit exceeds the preset upload threshold, a log will be generated and output to the user to inform the number of file upload failures. For example, 3 means that the file has failed to upload twice in a row. A log will be generated to record the number of file upload failures and output to the user.
[0091] Through the design of cache mechanism and business implementation class, efficient file upload management is achieved. The cache mechanism can quickly access and update the file upload status information, avoid repeated uploads, and save resources and time. The encapsulation of business implementation class realizes the decoupling and modularization of file generation logic, improving flexibility and scalability. In addition, it also provides error tracking support by recording the number of upload failures and outputting logs, which improves the user experience.
[0092] Next, with respect to the description of the foregoing embodiment, a possible specific scenario is provided to introduce the file upload method of the present application:
[0093] This scenario is a scenario where an account manager handles a consumer loan for a customer on-site. The steps and actions for the file upload method are as follows:
[0094] Gets a file upload request containing file types. This request can be triggered by the account manager on-site by entering the customer's identity information and starting the face verification operation, involving two file types: identity information storage and biometric image information storage.
[0095] Load pre-configured business implementation classes. Business implementation classes correspond to file types one by one and are used to assemble personalized information of specific types of files in the future. Examples of loaded business implementation classes include identity information preservation business implementation class, biometric image information preservation business implementation class, authorization preservation business implementation class, customer consumption flow preservation business implementation class, credit index preservation business implementation class, and industrial and commercial data information preservation business implementation class.
[0096] Traverse each business implementation class and make conditional judgments on the file type corresponding to each business implementation class. For the identity information preservation file type, confirm that it is included in the file upload request, execute the identity information preservation business implementation class to check the corresponding type of file upload status information in the cache, and find that the first bit is 1, indicating that the file has not been uploaded, so continue to perform subsequent operations.
[0097] Assemble the public information part of the file, call the corresponding personalized data configured in the cache through the identity information preservation business implementation class, assemble the personalized information part of the file, which can include name, ID number and nationality, generate the file and perform the upload operation. After the upload is successful, update the file upload status information and update the first bit value to 0, indicating that the upload is successful.
[0098] For the biological image information file type, repeat the above steps and find that the second bit of the file upload status information is also 1, and continue to execute the file generation and upload process. However, in subsequent processing, it is found that the file upload fails. The corresponding value of the file upload status information is updated to 2, indicating that the upload failed once.
[0099] The authorization letter file type is not included in the file upload request and does not meet the saving conditions, so it is skipped. Continue to traverse other business implementation classes until all loaded business implementation classes are traversed.
[0100] The automated and modularized file upload process improves business processing efficiency, enhances user experience, and achieves optimal resource utilization.
[0101] The file uploading device provided in the embodiment of the present application is described below. The file uploading device described below and the file uploading method described above can refer to each other.
[0102] See also Figure 3 , Figure 3 A schematic diagram of the structure of a file uploading device disclosed in an embodiment of the present application.
[0103] like Figure 3 As shown, the device may include:
[0104] A request acquisition unit 11 is used to acquire a file upload request, wherein the file upload request includes a file type;
[0105] A business implementation class loading unit 12 is used to load pre-configured business implementation classes, each of which corresponds to the file type one by one, and is used to assemble personalized information of the corresponding type of file;
[0106] The business implementation class traversal unit 13 is used to traverse each business implementation class one by one, and for the currently traversed business implementation class:
[0107] Determine whether the file type corresponding to the currently traversed business implementation class is included in the file upload request. If not, skip the currently traversed business implementation class. If so, obtain the file upload status information configured in the cache. Based on the file upload status information, determine whether the file type corresponding to the currently traversed business implementation class has been uploaded. The file upload status information records the correspondence between different business implementation classes and upload statuses. The upload status corresponding to any business implementation class indicates whether the file type corresponding to the business implementation class has been uploaded.
[0108] If the file of the type corresponding to the currently traversed business implementation class has not been uploaded, obtain the public information of the file to assemble the public information part of the file, use the currently traversed business implementation class to obtain the corresponding personalized data in the cache and assemble the personalized information part of the file, and the public information part and the personalized information part constitute the file;
[0109] Upload said file;
[0110] The file upload status information is updated according to the upload result of the file.
[0111] Optionally, the file upload status information is stored in a one-dimensional structure, the one-dimensional structure includes a number of data bits, different data bits correspond to different business implementation classes, and the data bits represent different upload statuses of files of the type corresponding to the corresponding business implementation class by storing different numerical values.
[0112] Optionally, the value stored in the data bit is a first value, a second value or a third value, the first value indicates that the file is uploaded successfully, the second value indicates that the file is not uploaded, and the third value indicates that the file upload fails.
[0113] Optionally, the process of the business implementation class traversal unit 13 judging whether a file of a type corresponding to the currently traversed business implementation class has been uploaded based on the file upload status information includes:
[0114] If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the first value, then the file of the type corresponding to the currently traversed business implementation class has been uploaded;
[0115] If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the second value or the third value, then the file of the type corresponding to the currently traversed business implementation class is not uploaded.
[0116] Optionally, the first value is 0, the second value is 1, and the third value is m, where m is a value greater than 1;
[0117] Accordingly, the process of the business implementation class traversal unit 13 updating the file upload status information according to the upload result of the file includes:
[0118] If the file is uploaded successfully, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is updated to 0;
[0119] If the file upload fails, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is increased by 1.
[0120] Optionally, the process in which the business implementation class traversal unit 13 determines whether a file of a type corresponding to the currently traversed business implementation class has been uploaded based on the file upload status information further includes:
[0121] If the value stored in the data bit in the file upload status information is greater than a preset upload threshold, a log indicating the number of times the file has failed to be uploaded is generated according to the value stored in the data bit and output to the user.
[0122] Optionally, the personalized data includes:
[0123] The identifier of the business implementation class and the personalized data information of the file of the type corresponding to the business implementation class.
[0124] The present application also provides an electronic device in an embodiment. Figure 4 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, tablet computers, teaching large screens, wearable devices, etc. Figure 4 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0125] like Figure 4As shown, the electronic device may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603 to implement the file upload method of the aforementioned embodiment of the present application. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0126] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0127] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any file uploading method provided in the embodiment of the present application.
[0128] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any file uploading method provided in the embodiment of the present application.
[0129] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0130] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0131] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0132] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
[0133] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0134] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0135] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A file uploading method, characterized in that: include: Obtain a file upload request, wherein the file upload request includes a file type; Loading pre-configured business implementation classes, each of which corresponds to the file type one by one, and is used to assemble personalized information of the corresponding type of file; Traverse each business implementation class one by one. For the currently traversed business implementation class: Determine whether the file type corresponding to the currently traversed business implementation class is included in the file upload request. If not, skip the currently traversed business implementation class. If so, obtain the file upload status information configured in the cache. Based on the file upload status information, determine whether the file type corresponding to the currently traversed business implementation class has been uploaded. The file upload status information records the correspondence between different business implementation classes and upload statuses. The upload status corresponding to any business implementation class indicates whether the file type corresponding to the business implementation class has been uploaded. If the file of the type corresponding to the currently traversed business implementation class has not been uploaded, obtain the public information of the file to assemble the public information part of the file, use the currently traversed business implementation class to obtain the corresponding personalized data in the cache and assemble the personalized information part of the file, and the public information part and the personalized information part constitute the file; Upload said file; The file upload status information is updated according to the upload result of the file.
2. The method according to claim 1, characterized in that The file upload status information is stored in a one-dimensional structure, which includes a number of data bits, different data bits correspond to different business implementation classes, and the data bits represent different upload states of files of the type corresponding to the corresponding business implementation class by storing different numerical values.
3. The method according to claim 2, characterized in that The value stored in the data bit is a first value, a second value or a third value, the first value indicates that the file is uploaded successfully, the second value indicates that the file is not uploaded, and the third value indicates that the file is uploaded unsuccessfully.
4. The method according to claim 3, characterized in that: The determining, based on the file upload status information, whether a file of a type corresponding to the currently traversed business implementation class has been uploaded includes: If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the first value, then the file of the type corresponding to the currently traversed business implementation class has been uploaded; If the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is the second value or the third value, then the file of the type corresponding to the currently traversed business implementation class is not uploaded.
5. The method according to claim 3, characterized in that: The first value is 0, the second value is 1, and the third value is m, where m is a value greater than 1; Correspondingly, updating the file upload status information according to the upload result of the file includes: If the file is uploaded successfully, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is updated to 0; If the file upload fails, the value stored in the data bit corresponding to the currently traversed business implementation class in the file upload status information is increased by 1.
6. The method according to claim 5, characterized in that Also includes: If the value stored in the data bit in the file upload status information is greater than a preset upload threshold, a log indicating the number of times the file has failed to be uploaded is generated according to the value stored in the data bit and output to the user.
7. The method according to claim 1, characterized in that The personalization data includes: The identifier of the business implementation class and the personalized data information of the file of the type corresponding to the business implementation class.
8. A file uploading device, characterized in that: include: A request acquisition unit, used to acquire a file upload request, wherein the file upload request includes a file type; A business implementation class loading unit, used to load pre-configured business implementation classes, the business implementation classes correspond to the file types one by one, and are used to assemble personalized information of files of corresponding types; The business implementation class traversal unit is used to traverse each business implementation class one by one. For the currently traversed business implementation class: Determine whether the file type corresponding to the currently traversed business implementation class is included in the file upload request. If not, skip the currently traversed business implementation class. If so, obtain the file upload status information configured in the cache. Based on the file upload status information, determine whether the file type corresponding to the currently traversed business implementation class has been uploaded. The file upload status information records the correspondence between different business implementation classes and upload statuses. The upload status corresponding to any business implementation class indicates whether the file type corresponding to the business implementation class has been uploaded. If the file of the type corresponding to the currently traversed business implementation class has not been uploaded, obtain the public information of the file to assemble the public information part of the file, use the currently traversed business implementation class to obtain the corresponding personalized data in the cache and assemble the personalized information part of the file, and the public information part and the personalized information part constitute the file; Upload said file; The file upload status information is updated according to the upload result of the file.
9. An electronic device, characterized in that: include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the file uploading method as described in any one of claims 1 to 7.
10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the file uploading method as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and system for dynamically converting telecommunications service data
CN101958987A
Method for data transmission and network-side equipment
CN102111250A
Data transmission method and equipment
CN108390741A
Bitmap-based data packet fragmentation transmission method
CN112073535A
File acquisition method and device, electronic equipment and readable storage medium
CN116361242A