A file preview method, device and equipment and computer storage medium

By dynamically adjusting the file preview method and storing the source file and preview file separately, the problems of long response time and redundant storage space in large file preview scenarios are solved, achieving efficient and secure file preview.

CN116166619BActive Publication Date: 2026-02-03CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111413413.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-25
Publication Date
2026-02-03
Estimated Expiration
2041-11-25

AI Technical Summary

Technical Problem

Existing file preview technologies have long response times in large file preview scenarios, are prone to crashing under high server load, and asynchronous preview methods result in redundant storage space and difficulty in protecting source file data.

Method used

The preview method is dynamically adjusted based on the size of the source file. Small files are generated using synchronous preview and large files are generated using asynchronous preview. The source file and preview file are stored separately to improve server load balancing and storage space utilization.

Benefits of technology

It improves the efficiency and accuracy of file preview, enhances the security of source files, and improves the utilization of storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116166619B_ABST
    Figure CN116166619B_ABST
Patent Text Reader

Abstract

The application discloses a file preview method and device, equipment and computer storage medium, the method comprises the following steps: receiving the file preview request sent by the client; wherein, the source file identifier of the target source file is carried in the file preview request; according to the source file identifier, the source file information of the target source file is acquired; in the case that the preview file information associated with the source file information is not detected according to the source file information, the file size of the target source file is determined according to the source file information; if the file size of the target source file is less than the preview threshold, the preview file is generated by using the synchronous preview mode; if the file size of the target source file is greater than or equal to the preview threshold, the preview file is generated by using the asynchronous preview mode; the preview file is returned to the client for file preview. In this way, the file preview mode can be dynamically adjusted according to the current server pressure, and when the synchronous preview pressure is too large, it can be converted into the asynchronous preview mode, so that the accuracy and response speed of file preview are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information technology application technology, and in particular to a file preview method, apparatus, device, and computer storage medium. Background Technology

[0002] With the development of the big data era, more and more data is recorded in the form of electronic files on servers. In daily use, users need to frequently view the content of stored files. To meet this need, file preview technology has emerged.

[0003] In related technologies, based on implementation methods, common file preview technologies are mainly divided into synchronous file preview and asynchronous file preview. For synchronous preview, response time and file size show a positive correlation; the long response time is amplified in large file preview scenarios, leading to a poor user experience. However, real-time file conversion places high demands on the processing performance of the conversion server. Under high concurrency file conversion requests, the server is prone to preview failures or even service outages. Asynchronous preview requires additional storage of the preview file. Storing one file necessitates double the storage space for both the source and preview files, resulting in significant redundant space overhead. Furthermore, since both the source and preview files are electronic documents, existing asynchronous preview solutions store them in the same storage area, posing challenges to source file data protection and reducing storage space utilization. Summary of the Invention

[0004] This application proposes a file preview method, apparatus, device, and computer storage medium, which not only improves the efficiency of file preview but also improves the security and reliability of protecting the source file by storing the source file and the preview file separately, while also increasing the utilization rate of storage space.

[0005] To achieve the above objectives, the technical solution of this application is implemented as follows:

[0006] In a first aspect, embodiments of this application provide a file preview method, the method comprising:

[0007] Receive a file preview request sent by the client; the file preview request carries the source file identifier of the target source file;

[0008] Based on the source file identifier, obtain the source file information of the target source file;

[0009] If no associated preview file information is detected based on the source file information, the file size of the target source file is determined based on the source file information.

[0010] If the size of the target source file is smaller than the preview threshold, a preview file will be generated using the synchronous preview method.

[0011] If the size of the target source file is greater than or equal to the preview threshold, an asynchronous preview method will be used to generate a preview file.

[0012] The preview file is returned to the client for file preview.

[0013] Secondly, embodiments of this application provide a file preview device, which includes a receiving unit, an acquiring unit, and a preview unit, wherein...

[0014] The receiving unit is configured to receive a file preview request for a source file; wherein the file preview request carries a source file identifier;

[0015] The acquisition unit is configured to retrieve source file information and corresponding preview file information based on the source file identifier.

[0016] The preview unit is configured to retrieve the preview file based on the preview file information if the source file has corresponding preview file information.

[0017] The preview unit is also configured to retrieve the source file based on the source file information and generate a preview file synchronously based on the source file if the source file does not have corresponding preview file information.

[0018] Thirdly, embodiments of this application provide an electronic device, which includes: a memory and a processor; wherein,

[0019] The memory is used to store computer programs that can run on the processor;

[0020] The processor is configured to execute the method as described in the first aspect when running the computer program.

[0021] Fourthly, embodiments of this application provide a computer storage medium storing a file preview program, which, when executed by at least one processor, implements the method described in the first aspect.

[0022] This application provides a file preview method, apparatus, device, and computer storage medium that receives a file preview request sent by a client. The file preview request carries a source file identifier for the target source file. Based on the source file identifier, the source file information of the target source file is obtained. If no associated preview file information is detected based on the source file information, the file size of the target source file is determined based on the source file information. If the file size of the target source file is less than a preview threshold, a preview file is generated using a synchronous preview method. If the file size of the target source file is greater than or equal to the preview threshold, a preview file is generated using an asynchronous preview method. The preview file is then returned to the client for file preview. This allows for dynamic adjustment of the file preview method based on the current server load during the file preview process. When the synchronous preview load is too high, it can be switched to an asynchronous preview method, improving the accuracy and response speed of the file preview, thereby increasing the efficiency of the file preview. Furthermore, since the source file and preview file are stored separately, the security and reliability of the source file are improved, while also increasing the utilization of storage space. Attached Figure Description

[0023] Figure 1 A flowchart illustrating a file preview method provided in an embodiment of this application;

[0024] Figure 2 A flowchart illustrating a source file upload process provided for an embodiment of this application;

[0025] Figure 3 This is a functional architecture diagram of a file preview method provided in an embodiment of this application;

[0026] Figure 4 A detailed flowchart illustrating a file preview method provided in this application embodiment;

[0027] Figure 5 A detailed flowchart illustrating a source file upload process provided for an embodiment of this application;

[0028] Figure 6 This is a schematic diagram of the composition structure of a file preview device provided in an embodiment of this application;

[0029] Figure 7 A schematic diagram of the composition structure of an electronic device provided in an embodiment of this application;

[0030] Figure 8 This is a schematic diagram of the composition structure of another electronic device provided in an embodiment of this application. Detailed Implementation

[0031] In order to gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit the embodiments of this application.

[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0033] In the following description, references to "some embodiments" refer to a subset of all possible embodiments. It is understood that "some embodiments" may be the same or different subsets of all possible embodiments and may be combined with each other without conflict. It should also be noted that the terms "first, second, third" used in the embodiments of this application are merely for distinguishing similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0034] In practical applications, file preview technology works by first converting the source file into a unified target type, then rendering the target type content information on the terminal, ultimately allowing users to directly preview the file. Based on their implementation methods, common file preview technologies can be mainly divided into the following two types:

[0035] (1) Synchronous file preview technology: After a user initiates a file preview request, a preview file is generated in real time and transmitted to the terminal for content rendering. This technology is relatively simple to implement, and because the file stream is returned directly after generation, it does not occupy additional storage space on the server, and the persistence of the source file is also more secure and reliable.

[0036] (2) Asynchronous file preview technology: File conversion is performed when the user uploads a file, and the generated preview file can be obtained after the user initiates a file preview request. Asynchronous file preview technology reduces the time loss caused by generating preview files during the preview process, and has a significant improvement in response speed for large file preview scenarios.

[0037] In related technologies, the following problems exist for file synchronous preview technology: the response time and file size show a positive correlation in synchronous preview, and the long response time will be amplified in the scenario of large file preview, resulting in a poor user experience; in addition, real-time file conversion has high requirements for the processing performance of conversion server. When faced with high concurrency file conversion requests, the server is prone to preview failure under high load, or even service crash.

[0038] For file synchronous preview technology, the following problems exist: asynchronous preview requires additional recording of preview files. Storing a single file requires double the storage space to store the source file and preview file separately, resulting in significant redundant space overhead. In addition, since both the source file and preview file are in electronic file form, in existing asynchronous preview schemes, the source file and preview file are stored in the same storage area, which poses a challenge to the data protection of the source file.

[0039] It is evident that while related technologies have optimized file preview technology, they cannot achieve a good balance in terms of time and space. The embodiments of this application aim to solve the problem of inefficient previewing caused by large file previewing and high concurrency requests in related technologies, as well as the problem of low storage utilization caused by unified storage of source files and preview files.

[0040] Based on this, this application provides a file preview method. The basic idea of ​​this method is as follows: receiving a file preview request sent by a client; wherein the file preview request carries the source file identifier of the target source file; obtaining the source file information of the target source file based on the source file identifier; if no preview file information associated with the source file information is detected, determining the file size of the target source file based on the source file information; if the file size of the target source file is less than a preview threshold, generating a preview file using a synchronous preview method; if the file size of the target source file is greater than or equal to the preview threshold, generating a preview file using an asynchronous preview method; and returning the preview file to the client for file preview. In this way, during the file preview process, the file preview method can be dynamically adjusted according to the current server load. When the synchronous preview load is too high, it can be switched to an asynchronous preview method, improving the accuracy and response speed of the file preview, thereby improving the efficiency of the file preview. In addition, since the source file and the preview file are stored separately, the security and reliability of the source file are improved, while also increasing the utilization rate of storage space.

[0041] Example 1

[0042] In one embodiment of this application, see [link to embodiment]. Figure 1 This illustrates a flowchart of a file preview method provided in an embodiment of this application. Figure 1 As shown, the method may include:

[0043] S101: Receive a file preview request sent by the client; wherein the file preview request carries the source file identifier of the target source file.

[0044] It should be noted that the file preview method provided in this application embodiment can be applied to a device for file previewing, or an electronic device integrated with such a device. Here, the electronic device may be such as a computer, smartphone, tablet computer, laptop computer, handheld computer, personal digital assistant (PDA), navigation device, server, etc., and this application embodiment does not specifically limit it in this regard.

[0045] It should also be noted that if the electronic device in this application embodiment specifically refers to a server, then when the client receives an operation that triggers real-time preview by the user, such as clicking the "Real-time Preview" button on the client interface, it can send a file preview request to the server; then after the server receives the file preview request, it can also learn the source file identifier of the target source file carried in the file preview request.

[0046] S102: Obtain the source file information of the target source file based on the source file identifier.

[0047] It should be noted that the source file information of the target source file can be obtained based on the source file identifier. In the embodiments of this application, the source file information may specifically include the source file identifier, source file name, source file type, source file size, source file hash value, and source file storage address. In practical applications, the source file information can also be expanded and supplemented, and no limitations are made here.

[0048] It should also be noted that, under normal circumstances, when a file preview request is received from a user, synchronous preview is preferred. However, if the file is too large or there are multiple file preview requests at the same time, exceeding the reasonable load range of the conversion server, then asynchronous preview is required based on the source file identifier in the file preview request.

[0049] Thus, after obtaining the source file information, this embodiment of the application can first determine whether there is preview file information associated with the source file information, and then, in combination with the current conversion server pressure, determine how to implement file preview.

[0050] S103: If no associated preview file information is detected based on the source file information, determine the file size of the target source file based on the source file information.

[0051] It should be noted that during the source file upload process, a preliminary preview mode determination is performed on the source file to determine whether a preview file needs to be generated in advance. Therefore, if no preview file information associated with the source file is detected when retrieving the source file information, a second preview mode determination is needed to determine the file size of the target source file and thus determine whether the final preview mode is synchronous or asynchronous.

[0052] It should also be noted that, when determining whether preview file information associated with the source file is detected based on the source file information, it can be specifically determined whether the preview file identifier in the source file information is empty. If it is empty, it means that there is no preview file associated with the source file, that is, no preview file information associated with it is detected. In this case, it is necessary to determine the file size of the target source file based on the source file information. If it is not empty, it means that there is a preview file associated with the source file.

[0053] Furthermore, in cases where a preview file associated with the source file exists, in some embodiments, the method may further include:

[0054] If the preview file information associated with the source file information is detected, the storage address of the preview file is obtained based on the preview file information;

[0055] Retrieve the preview file corresponding to the preview file storage address from the preview file storage area;

[0056] The preview file is returned to the client for file preview.

[0057] It should be noted that if corresponding preview file information is detected during the process of obtaining source file information, it means that the source file was confirmed to require asynchronous previewing when it was uploaded. At this point, the preview file storage address is obtained from the preview file information, the preview file corresponding to that storage address is retrieved from the preview file storage area, and the preview effect is rendered on the client side for display to the user.

[0058] It should also be noted that the process of obtaining the preview file can be as follows: first, obtain the source file information through the source file identifier; then, obtain the preview file information based on the preview file identifier in the source file information; and finally, obtain the preview file based on the preview file storage address in the preview file information.

[0059] S104: If the file size of the target source file is less than the preview threshold, then a preview file will be generated using the synchronous preview method.

[0060] It should be noted that if the target source file is not too large within the reasonable load range of the conversion server, and there are no concurrent file preview requests exceeding the load, then a synchronous preview method can be used to directly generate a preview file from the target source file for previewing.

[0061] Specifically, in some embodiments, when the file size of the target source file is less than the preview threshold, generating the preview file using the synchronous preview method may include:

[0062] Based on the source file information, determine the source file storage address of the target source file;

[0063] Retrieve the target source file corresponding to the source file storage address from the source file storage area, and generate a preview file in real time based on the target source file.

[0064] In this embodiment of the application, after obtaining the source file, a preset software tool (such as OpenOffice software) is used to convert the source file into a portable document type (such as PDF type) in real time, and then the file stream is returned to the client for preview rendering.

[0065] S105: If the file size of the target source file is greater than or equal to the preview threshold, then generate a preview file using asynchronous preview.

[0066] It should be noted that when file preview requests exceed the reasonable load range of the conversion server, such as when the target source file is too large or there are high-concurrency file preview requests, an asynchronous preview method can be used. In this case, a preview file is first generated and stored, and then the preview file is retrieved directly from the preview file storage area at an appropriate time for file preview.

[0067] Specifically, in some embodiments, when the file size of the target source file is greater than or equal to the preview threshold, generating the preview file using an asynchronous preview method may include:

[0068] Update the preview file identifier in the source file information; the preview file identifier is randomly generated using the snowflake algorithm.

[0069] Based on the source file information, determine the source file storage address of the target source file, and retrieve the target source file corresponding to the source file storage address from the source file storage area;

[0070] Use the preview file identifier and the target source file to form a key-value pair, and put the key-value pair into the asynchronous preview queue;

[0071] If the key-value pair is at the head of the asynchronous preview queue, a preview file is generated based on the target source file and uploaded to the preview file storage area.

[0072] It should be noted that updating the preview file identifier in the source file information involves replacing the originally empty preview file identifier in the source file information with a random string, which will then serve as the preview file identifier for the preview file to be generated.

[0073] It should also be noted that key-value pairs, also known as attribute-value pairs, can be expanded according to actual needs. In one specific embodiment, the key-value pair corresponding to the target source file that has already received a file preview request can be placed at the front of the asynchronous preview queue to avoid affecting the user experience.

[0074] Furthermore, in some embodiments, after updating the preview file identifier in the source file information, the method may further include:

[0075] Based on the preview file identifier, record the preview file information corresponding to the target source file; among which, the preview file status in the preview file information is "in preview".

[0076] After uploading the preview file to the preview file storage area, determine the preview file storage address and the preview file size;

[0077] The preview file information is updated using the preview file's storage address and file size, and the updated preview file information shows the preview file status as "preview complete".

[0078] It should be noted that, in some specific embodiments, the preview file information may include the preview file storage address, preview file size, preview file status, number of uploads, earliest upload time, last upload time, number of previews, earliest preview time, and last preview time. Therefore, after the preview file is stored, this preview file information needs to be updated promptly.

[0079] S106: Return the preview file to the client for file preview.

[0080] It should be noted that for the preview files obtained in S104 and S105, the target source file can be formatted (e.g., converted to PDF) using OpenOffice software, and then the preview file stream can be returned to the client for preview rendering. Here, OpenOffice is a cross-platform office suite commonly used for file conversion.

[0081] It should also be noted that the preview threshold in this embodiment is estimated in real time based on the performance parameters of the conversion server and the source file information. Thus, by comprehensively estimating the maximum conversion size that the current conversion server can handle based on the conversion server performance parameters and source file characteristics, the synchronous / asynchronous file conversion method is adaptively selected. Furthermore, a queue mode is introduced in the asynchronous preview mode to handle large files and high-concurrency preview scenarios. In other words, the preview threshold in this embodiment can be dynamically updated based on the conversion server load.

[0082] In summary, this embodiment provides a file preview method by receiving a file preview request sent by a client. The file preview request carries the source file identifier of the target source file. Based on the source file identifier, the source file information of the target source file is obtained. If no associated preview file information is detected based on the source file information, the file size of the target source file is determined based on the source file information. If the file size of the target source file is less than a preview threshold, a preview file is generated using synchronous preview. If the file size of the target source file is greater than or equal to the preview threshold, a preview file is generated using asynchronous preview. The preview file is then returned to the client for file preview. In this way, during the file preview process, the file preview method can be dynamically adjusted according to the current server load. When the synchronous preview load is too high, it can be switched to asynchronous preview, improving the accuracy and response speed of file preview, thereby increasing the efficiency of file preview. Furthermore, since the source file and preview file are stored separately, the security and reliability of the source file are improved, while also increasing the utilization of storage space.

[0083] Example 2

[0084] Before receiving a file preview request from the client, this embodiment of the application requires the file to be uploaded first. See also Figure 2 It illustrates a flowchart of a file upload process. For example... Figure 2 As shown, the method may include:

[0085] S201: Receive source files uploaded by the client.

[0086] S202: If it is determined that there are no duplicate source files, upload the source files to the source file storage area and determine the file size of the source files.

[0087] It should be noted that after receiving the source file uploaded by the client, the first step is to determine whether the source file is duplicated.

[0088] In some embodiments, the method for determining whether a source file is duplicated may further include:

[0089] Get the first file type and first file hash value corresponding to the source file;

[0090] Query the first file type and the first file hash value in the source file information table;

[0091] If a first source file exists that has the same type and hash value as the first file, then the source file is determined to be duplicated, and the storage address of the source file and the preview file identifier in the first source file information are confirmed as the storage address of the first source file and the first preview file identifier corresponding to the source file.

[0092] It should be noted that the embodiments of this application use the source file type and source file hash value to query whether the source file is duplicated. In practical applications, other content in the source file information can also be used for deduplication operation as appropriate, provided that the source file information used for deduplication is a unique identifier for the source file and does not affect the deduplication effect.

[0093] It should also be noted that if a source file is duplicated, the source file storage address and preview file identifier in the source file information can be updated to the same source file storage address and preview file identifier in the same record. If there is no first source file with the same first file type and first file hash value, it means that the source file is not duplicated. In this case, the source file needs to be uploaded to the source file storage area, and the file size of the source file needs to be determined.

[0094] S203: If the file size of the source file is less than the preview threshold, record the source file information corresponding to the source file.

[0095] It should be noted that if the file size of the source file is less than the preview threshold, it means that the source file was determined to be previewed synchronously during the initial preview method judgment during the source file upload process. At this time, it is only necessary to obtain the source file information so that when a file preview request is received later, the source file can be directly converted into a preview file for preview on the client.

[0096] It should also be noted that for synchronous preview, when a file preview request is received, considering the real-time pressure on the server, it is necessary to compare the source file size with the real-time preview threshold, that is, to perform a second preview method judgment, so as to finally determine whether the source file should be previewed asynchronously or synchronously.

[0097] S204: If the file size of the source file is greater than or equal to the preview threshold, record the preview file information and source file information corresponding to the source file, and generate the preview file corresponding to the source file using the asynchronous preview method.

[0098] It should be noted that during the source file upload process, if the file size of the source file is less than the preview threshold, the source file information corresponding to the source file needs to be recorded in the preset source file information table; wherein, the preview file identifier in the source file information is set to empty, and the source file identifier in the source file information is randomly generated by the snowflake algorithm.

[0099] It should also be noted that during the source file upload process, if the file size of the source file is greater than or equal to the preview threshold, then the preview file information corresponding to the source file needs to be recorded in the preset preview file information table, and the source file information corresponding to the source file needs to be recorded in the preset source file information table; among them, the preview file identifier in the preview file information is randomly generated by the snowflake algorithm, and the source file identifier in the source file information is randomly generated by the snowflake algorithm.

[0100] In this way, if the file size of the source file is greater than or equal to the preview threshold, it means that after the initial preview method is determined during the source file upload process, it is determined that the source file needs to be previewed asynchronously. At this time, it is necessary to record the preview file information and source file information corresponding to the source file so that when the corresponding file preview request is received later, the preview file can be directly obtained from the preview file storage area and the file can be previewed on the client.

[0101] S205: After obtaining the current remaining space in the preview file storage area and the file size of the preview file, calculate the reserved remaining space in the preview file storage area based on the current remaining space and the file size of the preview file.

[0102] It should be noted that, in this embodiment of the application, the reserved remaining space in the preview file storage area can be calculated by subtracting the current remaining space from the file size of the preview file. For example, the preview file size is size. preview Get the current remaining space size of the preview file storage area as space. now So, reserve the remaining space size preview =space now -size preview .

[0103] S206: When the reserved remaining space is greater than or equal to the preset alarm threshold, the preview file is uploaded to the preview file storage area, and the recorded preview file information is updated. The preview file status in the updated preview file information is "preview completed".

[0104] It should be noted that when the remaining reserved space is less than the preset alarm threshold, the preview file storage area needs to be updated, that is, preview files with lower data value are deleted to make room for the latest preview files. Specifically, in some embodiments, before uploading the preview files to the preview file storage area, the method may further include:

[0105] When the reserved remaining space is less than the preset alarm threshold, a space release operation is performed on the preview file storage area so that the reserved remaining space in the preview file storage area after space release is greater than or equal to the preset alarm threshold.

[0106] In other words, in this embodiment of the application, the space release operation of the preview file storage area can specifically be to delete preview files whose preview file status is "preview complete" and whose data value is low.

[0107] In some embodiments, performing a space release operation on the preview file storage area may include:

[0108] Get the information of the first preview file whose preview status is "preview complete" and the first preview file corresponding to the first preview file information;

[0109] Based on the information from the first preview file, calculate the upload feature value, preview feature value, and file feature value;

[0110] The data value of the first preview file is obtained by weighting the upload feature value, preview feature value and file feature value using preset weight parameters.

[0111] After obtaining the data values ​​of multiple first preview files, they are sorted in descending order of data value to obtain a sorted list including multiple first preview files;

[0112] Determine at least one preview file to be deleted from the sorted list, and after obtaining the preview file storage address of at least one preview file to be deleted, delete at least one preview file to be deleted corresponding to the preview file storage address from the preview file storage area;

[0113] Among them, the data value of at least one preview file to be deleted is lower than the data value of the remaining preview files in the sorted list.

[0114] In one specific implementation, based on the information of the first preview file, information such as the last upload time, the earliest upload time, the current time, the last preview time, the earliest preview time, the number of previews, and the preview file size can be obtained. Based on this, the data value can be calculated as follows:

[0115] (1) Calculate the upload feature upload = ut × (last upload time - earliest upload time) / number of uploads + un × (current time - last upload time), where ut and un are preset weight parameters;

[0116] (2) Calculate the preview feature pvw = pt × (last preview time - earliest preview time) / number of previews + pn × (current time - last preview time), where pt and pn are preset weight parameters;

[0117] (3) Calculate the file feature: file = preview file size – preview threshold, which is updated in real time;

[0118] (4) Calculate the data value value = vs × file + vu × upload + vp × pvw, where vs, vu, and vp are preset weight parameters.

[0119] Furthermore, in some embodiments, the space release operation on the preview file storage area may further include:

[0120] Sort the preview files according to their data value from high to low to obtain a data value sequence, and then sum the sizes of the preview files sequentially to obtain a cumulative value.

[0121] If the first accumulated value is less than or equal to the preset release threshold, and the second accumulated value is greater than the preset release threshold, then delete the preset file corresponding to the second accumulated value, as well as all preview files that are ranked after the preview file in the data value sequence.

[0122] The cumulative value is the sum of the file sizes of the preview file and all the preview files preceding it in the data value sequence. The first cumulative value is the cumulative value corresponding to any preview file in the data value sequence. In the data value sequence, the preview file corresponding to the second cumulative value is ranked after the preview file corresponding to the first cumulative value.

[0123] For example, the list of preview files obtained by sorting according to data value is [f1,…,fv,fv+1,…,fu]. The file size of the corresponding preview file is accumulated sequentially until the accumulated value of the files [f1,…,fv] is less than or equal to the release threshold, and the accumulated value of the files [f1,…,fv+1] is greater than the release threshold. Then, the preview file ID and preview file storage address corresponding to [fv+1,…,fu] can be obtained, and the preview file corresponding to the preview file storage address in the preview file storage area can be deleted.

[0124] Furthermore, in this embodiment, the preview threshold is estimated in real time based on the performance parameters of the conversion server and the source file information. Therefore, in some embodiments, the method for determining the preview threshold may further include:

[0125] The conversion server is monitored once per minute to collect its performance parameters, which may include processor (Center Processing Unit, CPU) utilization, remaining memory size, and number of processes.

[0126] Within a preset time interval, calculate the current average CPU utilization, the current average remaining memory size, and the current average number of processes.

[0127] Based on the baseline CPU utilization, baseline remaining memory size, and baseline number of processes preset by the conversion server, as well as the current average CPU utilization, current average remaining memory size, and current average number of processes, calculate the difference CPU utilization, difference remaining memory size, and difference number of processes.

[0128] The pressure value is obtained by weighting the difference in CPU utilization, remaining memory size, and number of processes using preset weight parameters.

[0129] The baseline preview file size is determined based on the source file information. The preview threshold is obtained by adding the baseline preview file size and the pressure value.

[0130] For example, when the latest preview threshold is obtained, the average stress over n minutes is calculated every n minutes. First, the CPU utilization for each minute from minute 1 to minute n can be obtained, denoted by c1, ..., c... n This represents the remaining memory size per minute, denoted by m1, ..., m. n The number of processes per minute is represented by t1, ..., t. n This means that the average CPU utilization c of the conversion server over n minutes can be calculated separately. now = (c1+…+c n ) / n, Current average remaining memory size m now =(m1+…+m n ) / n, current average number of processes t now =(t1+…+t) n ) / n; where n is an integer greater than 1.

[0131] Then, calculate the pressure value p = i × (c now -c base )+j×(m now -m base )+k×(t now -t base ),c base The preset baseline CPU utilization for the conversion server, m baset is the preset baseline remaining memory size of the conversion server. base The preset baseline number of conversion server processes is denoted by i, j, and k, which are preset weight parameters.

[0132] Finally, according to the formula preview max =preview base +p; Calculate the current preview threshold. max Among them, preview base This is the preset baseline preview file size.

[0133] This embodiment provides a file preview method. Through the above embodiment, the specific implementation of the aforementioned embodiment has been described in detail. It can be seen that, through the technical solution of the aforementioned embodiment, the file preview method can be dynamically adjusted according to the current server pressure during the file preview process. When the synchronous preview pressure is too high, it can be switched to the asynchronous preview method, which improves the accuracy and response speed of file preview, thereby improving the efficiency of file preview. In addition, since the source file and the preview file are stored separately, the security and reliability of the source file are improved, while the utilization rate of storage space is also improved.

[0134] Example 3

[0135] Based on the same inventive concept as the foregoing embodiments, see [link to previous document]. Figure 3 This illustrates a functional architecture diagram of a file preview method provided in an embodiment of this application. Figure 3 As shown, the method may include an upload module 301, a preview module 302, and a storage module 303; wherein,

[0136] Upload module 301: Provides users with a graphical file upload interface; and can verify the duplication of source files.

[0137] Preview module 302: Provides users with a graphical file preview entry; can also generate preview files; and can verify the duplication of preview files.

[0138] Storage module 303 is divided into three parts: a basic information storage area, a source file storage area, and a preview file storage area. The basic information storage area uses a relational database to record source file information and preview file information.

[0139] Specifically, in the storage module, the source file storage area and the preview file storage area use file systems to store the source files and preview files respectively. Because the source files need to be persistently stored for a long time, the source files and preview files are physically separated here to maximize the security and reliability of the source files. The preview file storage area is a temporary storage area allocated to improve preview performance. Low-value data can be promptly cleared through the space release process to improve space utilization.

[0140] In some specific embodiments, the contents of the source file information table in the database design are shown in Table 1, and the contents of the preview file information table are shown in Table 2.

[0141] Table 1

[0142] field name describe Sample Source file identifier Primary key, unique identifier 1354014251905 Source file name Source file name Upload file.docx Source file type Source file type docx Source file size Source file size, in bytes 1122 Source file hash value Source file hash value 202dc462c334d9 Source file storage address The storage address of the source file in the source file storage area M00 / 00 / 1905.docx Preview file identifier Related fields in the preview file information table 1354014251906

[0143] As shown in Table 1, the source file information table stores basic and associated information of the source files. The source file information table and the preview file information table are linked through the preview file identifier field in the source file information table. The fields listed above are the essential key fields for the source files in this application, and can be expanded as needed in practical applications. The basic information of the source file may include the source file identifier, source file name, source file type, source file size, source file hash value, and source file storage address; the associated information of the source file may include the preview file identifier.

[0144] Table 2

[0145]

[0146] As shown in Table 2, the preview file information table stores the basic and characteristic information of the preview file. The source file information table and the preview file information table are linked through the preview file identifier field in the source file information table. One source file can be associated with a maximum of one preview file, and one preview file can be associated with multiple source files. The fields listed above are the essential key fields for preview files in this application, and can be expanded as needed in practical applications. Among them, the basic information of the preview file may include the preview file identifier, the preview file storage address, and the preview file status; the characteristic information of the preview file may include the preview file size, number of uploads, earliest upload time, last upload time, number of previews, earliest preview time, and last preview time.

[0147] In this embodiment, the overall preview efficiency can be improved by dynamically adapting the file conversion method according to the storage area performance, redundant file storage can be reduced through a duplicate detection algorithm, and preview features collected from multiple dimensions can be converted into quantitative scores to provide data value basis for space release, thereby maximizing space utilization. The implementation details of the scheme will be described below from the three main processes of file preview, file upload, and space release.

[0148] Based on the file preview method provided in the above embodiments, in a specific embodiment, see [link to specific embodiment]. Figure 4 This illustrates a detailed flowchart of a file preview method provided in an embodiment of this application. Figure 4 As shown, the method may include:

[0149] S401: The user initiates a file preview request;

[0150] The file preview request must include the source file identifier.

[0151] S402: Obtain source file information and associated preview file information;

[0152] It should be noted that the source file information table and the preview file information table are retrieved based on the source file identifier passed in by S401. The two tables are linked through the preview file identifier field.

[0153] S403: Determine if a preview file has been generated;

[0154] It should be noted that if the associated preview file information is found in S402, it means that the corresponding preview file has been generated for the source file, and proceed to S404; if the associated preview file information is not found in S402, it means that a preview file needs to be generated, and proceed to S406.

[0155] S404: Update the preview file information table record;

[0156] It should be noted that the preview file identifier obtained in the preview file information obtained in S402 is used to query the corresponding record in the preview file information table, and the number of previews is updated = number of previews + 1, and the last preview time is the current time.

[0157] S405: Get preview file;

[0158] It should be noted that, based on the preview file storage address obtained in the preview file information in S402, the corresponding preview file is retrieved from the preview file storage area, and the file stream is returned to the client for preview effect rendering.

[0159] S406: Determine if the source file size is less than the preview threshold;

[0160] It should be noted that, when comparing the source file size in the source file information obtained in S402 with the preview threshold that is updated periodically, if the source file size is ≥ the preview threshold, proceed to step S407; if the source file size is < the preview threshold, proceed to step S408.

[0161] S407: Asynchronously generate preview files. For specific implementation details, please refer to the following:

[0162] 1) Update the preview file identifier of the record corresponding to the source file identifier in the source file information table to use the snowflake algorithm to generate random numbers;

[0163] 2) Add a new record to the preview file information table. The preview file identifier is the preview file identifier in step 1). The number of uploads and previews are both 1. The earliest upload time, the last upload time, the earliest preview time, and the last preview time are all the current time. The preview file status is 1 Previewing.

[0164] 3) Based on the source file storage address obtained in S402, retrieve the corresponding source file stream from the source file storage area;

[0165] 4) Construct a key-value pair [preview file identifier, source file stream], add the key-value pair to the asynchronous preview queue, if the current key-value pair is the first item in the asynchronous preview queue, use OpenOffice to convert the source file into a PDF type preview file, and pass the preview file to the preview file storage area, and record the preview file storage address;

[0166] 5) Return the preview file stream generated in step 4) to the client for preview rendering;

[0167] 6) Transfer the preview file generated in step 4) to the preview file storage area, update the preview file size of the record corresponding to the preview file identifier in the preview file information table to the file size of the file generated in step 4), set the preview file storage address to the address returned by the preview file storage area, and set the preview file status to 3 Preview complete.

[0168] S408: Synchronously generate preview files.

[0169] It should be noted that OpenOffice software is used to convert the source file into PDF format in real time, and the file stream is returned to the client for preview rendering.

[0170] Based on the file preview method provided in the above embodiments, in another specific embodiment, see [link to embodiment]. Figure 5 This illustrates a detailed flowchart of a file upload process provided in an embodiment of this application. Figure 5 As shown, the detailed process may include:

[0171] S501: User uploads source file;

[0172] It should be noted that in this embodiment of the application, the source files are uniformly converted into PDF file format for file preview, and the source files must be able to be converted into PDF file format.

[0173] S502: Determine if the source file is duplicated; the specific implementation method can be found below:

[0174] 1) Obtain the filename, file type, and file size from the source file, and set the source filename, source file type, and source file size in the source file information to the results obtained above;

[0175] 2) The source file hash value in the source file information is the calculated value after processing the file stream of the source file using the MD5 encryption algorithm. The MD5 encryption algorithm is a widely used cryptographic hash function that is simple to implement and can effectively determine the integrity and consistency of the same file.

[0176] 3) Because there are a large number of source files, the source file information table is queried to see if there are any identical records based on the source file type and source file hash value in order to quickly obtain the filtering results;

[0177] 4) If the same record exists in S502, it indicates that a duplicate source file already exists in the source file storage area. Set the source file storage address and preview file identifier in the source file information to the same source file storage address and preview file identifier in the same record, and proceed to S506.

[0178] 5) If no identical record exists in S502, it indicates that there is no duplicate source file, proceed to S503;

[0179] S503: Source file upload source file storage area.

[0180] Upload the source file to the file system in the source file storage area, and set the source file storage address in the source file information to the storage address returned by the file system.

[0181] A file system (i.e., a database) is a distributed file system, including but not limited to distributed storage FastDFS and data layer servers (Team Foundation Server, TFS). Through multi-node deployment, it can effectively cope with high concurrency and massive data storage scenarios.

[0182] S504: Update preview threshold max The specific implementation method can be found below:

[0183] 1) Configure a monitor on the conversion server to listen to it every minute. In high-concurrency, high-load application scenarios, the higher the CPU utilization, the smaller the remaining memory size, and the more processes on the conversion server, the fewer files the conversion server can still process, and the worse the conversion performance. Therefore, collect the CPU utilization c = [c1,…,c n Remaining memory size m = [m1, ..., m n The number of processes t = [t1, ..., t2] n As a stress indicator, n is the preset preview threshold timeout execution duration, and the conversion server is the server responsible for generating preview files in the preview module;

[0184] 2) Calculate the average pressure over n minutes: Calculate the average CPU utilization c of the conversion server over n minutes.now = (c1+…+c n ) / n, Current average remaining memory size m now =(m1+…+m n ) / n, current average number of processes t now =(t1+…+t) n ) / n;

[0185] 3) Calculate the pressure value p = i × (c now -c base )+j×(m now -m base )+k×(t now -t base ),c base The preset baseline CPU utilization for the conversion server, m base t is the preset baseline remaining memory size of the conversion server. base The preset baseline number of conversion server processes is denoted by i, j, and k, which are preset weight parameters.

[0186] 4) Calculate the current preview threshold. max The calculation formula is: preview max =preview base +p, preview base The preset baseline preview file size is used, and the preview threshold is the maximum source file size that the conversion server can convert in real time within an acceptable timeframe for the user.

[0187] S505: Determines if the source file size is less than the preview threshold; the specific implementation method can be found below:

[0188] 1) Because the source file size and the pressure on the conversion server directly affect the preview file generation time during the real-time conversion of the preview file, a preview threshold is set to distribute the real-time conversion pressure. The source file size obtained in S502 is compared with the current preview threshold input in S504. If the source file size is less than the preview threshold, it indicates that the conversion server under the current pressure can convert the preview file in real time within an acceptable time for the user. The preview file identifier in the source file information is set to empty, and then proceed to S506.

[0189] 2) If the source file size is greater than or equal to the preview threshold, it indicates that the real-time preview time is long, so proceed to step 107.

[0190] S506: Update the preview file information table record and add a source file information table record; the specific implementation method can be found below:

[0191] 1) Update the preview file information table record: If the preview file identifier in the source file information obtained in S502 is not empty, update the upload count of the corresponding record in the preview file information according to the preview file identifier = upload count + 1, and the last upload time is the current time;

[0192] 2) Add a new record to the source file information table: Set the source file identifier in the source file information to a random number generated by the snowflake algorithm, and store the source file information as a new record in the source file information table. The snowflake algorithm is a general unique identifier generation algorithm.

[0193] It should be noted that for S506, after completing the transition from S502 to S506, it may be necessary to update the preview file information table, so steps 1) and 2) should be executed; after completing the transition from S505 to S506, since it is a synchronous preview (there is no preview file during the process), it is not necessary to update the preview file information table, so only step 2) needs to be executed.

[0194] S507: Add a preview file information table record and a source file information table record; the specific implementation method can be found below:

[0195] 1) Add a new record to the preview file information table: Set the preview file identifier in the preview file information to a random number generated by the snowflake algorithm, the upload count to 1, the earliest upload time to the current time, the last upload time to the current time, and the preview file status to 1 Previewing. Store the preview file information as a new record in the preview file information table.

[0196] 2) Add a new record to the source file information table: Set the source file identifier in the source file information to a random number generated by the snowflake algorithm, and the preview file identifier to the preview file identifier set in step 1). Store the source file information as a new record in the source file information table. At this step, the source file upload is complete. Users can download the source file according to the source file identifier. The subsequent process is an asynchronous file preview process.

[0197] S508: Asynchronously generate preview files; the specific implementation method can be found below:

[0198] 1) Create a key-value pair [preview file identifier, source file stream] and put the key-value pair into the asynchronous preview queue. The asynchronous preview queue is a traffic distribution measure designed to cope with high-load preview scenarios, ensuring that the conversion server will not crash due to a surge in conversion demand;

[0199] 2) If the current key-value pair is the first item in the asynchronous preview queue, use OpenOffice to convert the source file to PDF type and then to S508. If the current key-value pair is not the first item in the asynchronous preview queue, continue to wait. OpenOffice is a cross-platform office software suite that is often used to handle file conversion.

[0200] S509: Determine the remaining space in the preview. preview Is it less than the alarm threshold space? min The specific implementation method can be found below:

[0201] 1) Calculate the size of the preview file generated in step 108.2. preview Get the current remaining space size in the preview file storage area. now Preview remaining space size preview =space now -size preview ;

[0202] 2) If space preview <space min This indicates that the current preview file storage area is running out of space and needs to be cleaned up. Proceed to step 110. If space is insufficient... preview ≥space min This indicates that the current preview file storage area can still store the source file. Proceed to step 111. The alarm threshold is the alarm value of the preset remaining space size of the preview file storage area.

[0203] S510: Triggers space release;

[0204] It should be noted that the specific procedures are detailed in S601-S605, and will not be repeated here;

[0205] S511: Preview file upload preview file storage area;

[0206] It should be noted that the preview file is uploaded to the file system in the preview file storage area, and the preview file storage address in the preview file information is set to the storage address returned by the file system;

[0207] S512: Update the preview file information table records.

[0208] It should be noted that, in updating the preview file information based on the preview file identifier, the preview file status is 3 (Preview Complete) and the preview file size is size. preview .

[0209] Unlike source files, which require long-term secure storage, preview files are temporary files created to improve the user experience. Even if all preview files are lost, they should not affect the functionality. Moreover, as usage frequency decreases, the data value of preview files will gradually decline. Storing a large number of low-value preview files will reduce the utilization of storage space and bring redundant storage costs. Therefore, it is necessary to release space in a timely manner and clean up low-value preview files.

[0210] In addition, in this embodiment of the application, space release can be triggered in two ways:

[0211] (1) Monitor the remaining space size of the preview file storage area periodically using the system-configured monitor. now If the current remaining space size is space now less than the alarm threshold space min Then, space release can be triggered.

[0212] Here, when the space release process is triggered periodically, the current remaining space size is compared. now With alarm threshold space min Specifically, when the space release process is actively triggered, such as in S509, to meet the needs of high-concurrency scenarios, it is necessary to ensure that the preview file storage area has sufficient space (enough to store the current preview file). Therefore, it is necessary to compare the remaining preview space size. now With alarm threshold space min .

[0213] (2) Actively trigger space release by asynchronously generating preview files. Specific methods may include:

[0214] Step 1: Obtain preview files with a preview status of 3 (preview complete) from the preview file information table;

[0215] Step 2: Calculate the value of the data sequentially; the specific implementation method can be found below:

[0216] 1) Calculate the upload feature upload = ut × (last upload time - earliest upload time) / number of uploads + un × (current time - last upload time), where ut and un are preset weight parameters;

[0217] 2) Calculate the preview feature pvw = pt × (last preview time - earliest preview time) / number of previews + pn × (current time - last preview time), where pt and pn are preset weight parameters;

[0218] 3) Calculate file characteristics: file = preview file size - update threshold;

[0219] 4) Calculate the data value value = vs × file + vu × upload + vp × pvw, where vs, vu, and vp are preset weight parameters.

[0220] Step 3: Sort the preview file list from highest to lowest data value. The resulting preview file list is [f1, ..., f v ,f v+1 ,…,f u ], and so on, incrementing the corresponding preview file sizes until [f1,…,f v The accumulated value of the file is less than or equal to the release threshold and [f1,…,f v+1 The cumulative value of the file exceeds the release threshold, which is the preset optimal size of the preview file storage area;

[0221] Step 4: Obtain [f] v+1 ,…,f u The preview file is identified by its corresponding preview file identifier and storage address. The preview file status of the record corresponding to the preview file identifier in the preview file information table is set to 0, and the preview file corresponding to the preview file storage address in the preview file storage area is deleted.

[0222] In this embodiment, the preview threshold dynamic update method based on server pressure estimates the maximum conversion size the current conversion server can handle by combining the performance parameters of the conversion server collected in S504 with the characteristics of the source file. This adaptively selects between synchronous and asynchronous file conversion methods and introduces a queue mode in the asynchronous preview mode to handle large files and high-concurrency preview scenarios. A data value update mechanism based on multiple features is also included. In S602, the data value of the preview file is comprehensively evaluated through three dimensions: upload features, preview features, and file features. In S506, S512, and S404, the collected parameters of upload and preview features are maintained based on the current operation, ensuring that the data value of the preview file is continuously updated according to time and frequency. Finally, a space release method based on data value is implemented. A dual-trigger mechanism is added to the space release process to balance the pressure of frequent monitoring and sudden traffic surges on the conversion server and storage area. The reuse potential of preview files is evaluated based on data value, low-value preview files are eliminated, and the utilization rate of the preview file storage area is improved.

[0223] The above embodiments have provided a detailed explanation of the specific implementation of the aforementioned embodiments. It can be seen that, through the technical solutions of the aforementioned embodiments, on the one hand, the embodiments of this application can dynamically adjust the file conversion method according to server pressure. When the synchronous preview pressure is high, it automatically switches to asynchronous preview mode, reducing functional errors caused by preview blocking or even service crashes during high-concurrency synchronous preview or low-performance server file conversion, thus improving the overall correctness and response speed of the file preview function. On the other hand, the embodiments of this application add a space release process, evaluating the data value of the preview file based on multiple characteristics and continuously updating it. The data value guides the reasonable release of redundant occupation of the preview file storage area, improving space utilization while ensuring the response speed of frequently previewed files. Furthermore, the embodiments of this application also divide the preview file storage area into isolated storage areas, protecting the security of the source file, introducing a queue mode, enabling successful previewing even under high load or large file scenarios, and dynamically selecting the preview file stream acquisition method in the file preview process, improving the fault tolerance of the preview solution.

[0224] Example 4

[0225] Based on the same inventive concept as the foregoing embodiments, see [link to previous document]. Figure 6 This illustrates a schematic diagram of the structural composition of a file preview device 60 provided in an embodiment of this application. Figure 6 As shown, the file preview device 60 may include: a receiving unit 601, an acquiring unit 602, a determining unit 603, and a previewing unit 604; wherein,

[0226] The receiving unit 601 is configured to receive a file preview request sent by a client; wherein the file preview request carries the source file identifier of the target source file;

[0227] The acquisition unit 602 is configured to acquire the source file information of the target source file based on the source file identifier;

[0228] The determining unit 603 is configured to determine the file size of the target source file based on the source file information if no associated preview file information is detected based on the source file information.

[0229] Preview unit 604 is configured to generate a preview file using synchronous preview if the file size of the target source file is less than the preview threshold; and to generate a preview file using asynchronous preview if the file size of the target source file is greater than or equal to the preview threshold; and to return the preview file to the client for file preview.

[0230] In some embodiments, the acquisition unit 602 is further configured to acquire the preview file storage address based on the preview file information when the preview file information associated with the source file information is detected.

[0231] The preview unit 604 is also configured to retrieve the preview file corresponding to the preview file storage address from the preview file storage area; and to return the preview file to the client for file preview.

[0232] In some embodiments, the preview unit 604 is specifically configured to determine the source file storage address of the target source file based on the source file information; and to obtain the target source file corresponding to the source file storage address from the source file storage area, and to generate a preview file in real time based on the target source file.

[0233] In some embodiments, the preview unit 604 is specifically configured to update the preview file identifier in the source file information; wherein the preview file identifier is randomly generated by the snowflake algorithm; and, based on the source file information, determine the source file storage address of the target source file, and obtain the target source file corresponding to the source file storage address from the source file storage area; and, use the preview file identifier and the target source file to form a key-value pair, and put the key-value pair into the asynchronous preview queue; and, if the key-value pair is at the head of the asynchronous preview queue, generate a preview file based on the target source file, and upload the preview file to the preview file storage area.

[0234] In some embodiments, the preview unit 604 is specifically configured to record preview file information corresponding to the target source file based on the preview file identifier; wherein the preview file status in the preview file information is "in preview"; and after uploading the preview file to the preview file storage area, determine the preview file storage address and the preview file size; and update the preview file information using the preview file storage address and the preview file size, wherein the preview file status in the updated preview file information is "preview complete".

[0235] In some embodiments, see Figure 6 The file preview device 60 may include an upload unit 605, configured to receive source files uploaded by a client; and, if it is determined that the source file does not contain duplicates, upload the source file to the source file storage area and determine the file size of the source file; and, if the file size of the source file is greater than or equal to a preview threshold, record the preview file information corresponding to the source file and the source file information, and generate the preview file corresponding to the source file using an asynchronous preview method; and, after obtaining the current remaining space in the preview file storage area and the file size of the preview file, calculate the reserved remaining space in the preview file storage area based on the current remaining space and the file size of the preview file; and, when the reserved remaining space is greater than or equal to a preset alarm threshold, upload the preview file to the preview file storage area and update the recorded preview file information, wherein the preview file status in the updated preview file information is "preview complete".

[0236] In some embodiments, the upload unit 605 is further configured to perform a space release operation on the preview file storage area when the reserved remaining space is less than a preset alarm threshold, so that the reserved remaining space of the preview file storage area after space release is greater than or equal to the preset alarm threshold.

[0237] In some embodiments, the upload unit 605 is specifically configured to: acquire information about a first preview file whose preview status is "preview complete" and the first preview file corresponding to the first preview file information; calculate upload feature value, preview feature value, and file feature value based on the first preview file information; perform weighted calculation on the upload feature value, preview feature value, and file feature value using a preset weight parameter to obtain the data value of the first preview file; after obtaining the data values ​​of multiple first preview files, sort them in descending order of data value to obtain a sorted list including multiple first preview files; determine at least one preview file to be deleted from the sorted list; and after obtaining the preview file storage address of at least one preview file to be deleted, delete at least one preview file to be deleted corresponding to the preview file storage address from the preview file storage area; wherein the data value of at least one preview file to be deleted is lower than the data value of the remaining preview files in the sorted list.

[0238] In some embodiments, the preview threshold is estimated in real time based on the performance parameters of the conversion server and the source file information. Correspondingly, the determining unit 603 is also configured to monitor the conversion server once per minute and collect the performance parameters of the conversion server. The performance parameters may include CPU utilization, remaining memory size, and number of processes. Within a preset time interval, the unit calculates the current average CPU utilization, current average remaining memory size, and current average number of processes. Based on the preset baseline CPU utilization, baseline remaining memory size, and baseline number of processes of the conversion server, as well as the current average CPU utilization, current average remaining memory size, and current average number of processes, the unit calculates the difference in CPU utilization, difference in remaining memory size, and difference in number of processes. The unit uses preset weighting parameters to perform a weighted calculation on the difference in CPU utilization, difference in remaining memory size, and difference in number of processes to obtain a stress value. Based on the source file information, the unit determines the baseline preview file size and adds the baseline preview file size and the stress value to obtain the preview threshold.

[0239] Understandably, in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular component. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.

[0240] If the integrated unit is implemented as a software functional module and not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0241] Therefore, this embodiment provides a computer storage medium storing a file preview program, which, when executed by at least one processor, implements the steps of the method described in any of the foregoing embodiments.

[0242] Based on the composition of the aforementioned file preview device 60 and the computer storage medium, see [link to relevant documentation]. Figure 7 This illustrates a schematic diagram of the specific hardware structure of the electronic device provided in an embodiment of this application. For example... Figure 7 As shown, electronic device 70 may include: a communication interface 701, a memory 702, and a processor 703; the various components are coupled together via a bus system 704. It is understood that the bus system 704 is used to implement communication between these components. In addition to a data bus, the bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 7 The various buses are all labeled as bus system 704. Among them, the communication interface 701 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;

[0243] Memory 702 is used to store computer programs that can run on processor 703;

[0244] Processor 703, when running the computer program, performs the following:

[0245] Receive a file preview request sent by the client; the file preview request carries the source file identifier of the target source file;

[0246] Based on the source file identifier, obtain the source file information of the target source file;

[0247] If no associated preview file information is detected based on the source file information, the file size of the target source file is determined based on the source file information.

[0248] If the size of the target source file is smaller than the preview threshold, a preview file will be generated using the synchronous preview method.

[0249] If the size of the target source file is greater than or equal to the preview threshold, an asynchronous preview method will be used to generate a preview file.

[0250] The preview file is returned to the client for file preview.

[0251] It is understood that the memory 702 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 702 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0252] The processor 703 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 703 or by software instructions. The processor 703 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 702, and the processor 703 reads the information in memory 702 and, in conjunction with its hardware, completes the steps of the above method.

[0253] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0254] For software implementation, the techniques described herein can be achieved through modules (e.g., procedures, functions, etc.) that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented within the processor or externally.

[0255] Alternatively, as another embodiment, the processor 703 is further configured to perform the steps of the method described in any of the foregoing embodiments when running the computer program.

[0256] Based on the composition of the aforementioned file preview device 60 and the computer storage medium, see [link to relevant documentation]. Figure 8 This illustrates a schematic diagram of the structural composition of another electronic device 70 provided in an embodiment of this application. For example... Figure 8 As shown, the electronic device 70 may include the file preview device 60 as described in any of the foregoing embodiments.

[0257] In this embodiment, the electronic device 70 receives a file preview request sent by a client. The file preview request carries a source file identifier for the target source file. Based on the source file identifier, the source file information of the target source file is obtained. If no associated preview file information is detected based on the source file information, the file size of the target source file is determined based on the source file information. If the file size of the target source file is less than a preview threshold, a preview file is generated using a synchronous preview method. If the file size of the target source file is greater than or equal to the preview threshold, a preview file is generated using an asynchronous preview method. The preview file is then returned to the client for file preview. In this way, during the file preview process, the file preview method can be dynamically adjusted according to the current server load. When the synchronous preview load is too high, it can be switched to an asynchronous preview method, improving the accuracy and response speed of the file preview, thereby increasing the efficiency of the file preview. Furthermore, since the source file and preview file are stored separately, the security and reliability of the source file are improved, while also increasing the utilization rate of storage space.

[0258] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0259] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0260] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0261] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.

[0262] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.

[0263] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A file preview method, characterized in that, The method includes: Receive a file preview request sent by the client; wherein the file preview request carries the source file identifier of the target source file; Based on the source file identifier, obtain the source file information of the target source file; If no associated preview file information is detected based on the source file information, the file size of the target source file is determined based on the source file information. If the file size of the target source file is less than the preview threshold, a preview file is generated using the synchronous preview method; If the file size of the target source file is greater than or equal to the preview threshold, a preview file is generated using an asynchronous preview method; The preview file is returned to the client for file preview; Wherein, when the file size of the target source file is greater than or equal to the preview threshold, the step of generating the preview file using the asynchronous preview method includes: Update the preview file identifier in the source file information; wherein, the preview file identifier is randomly generated using a snowflake algorithm; Based on the source file information, determine the source file storage address of the target source file, and retrieve the target source file corresponding to the source file storage address from the source file storage area; The preview file identifier and the target source file are used to form a key-value pair, and the key-value pair is placed into an asynchronous preview queue; If the key-value pair is at the beginning of the asynchronous preview queue, the preview file is generated based on the target source file, and the preview file is uploaded to the preview file storage area.

2. The method according to claim 1, characterized in that, The method further includes: If preview file information associated with the source file information is detected, the preview file storage address is obtained based on the preview file information. Retrieve the preview file corresponding to the preview file storage address from the preview file storage area; The preview file is returned to the client for file preview.

3. The method according to claim 1, characterized in that, When the file size of the target source file is less than the preview threshold, generating the preview file using the synchronous preview method includes: Based on the source file information, determine the source file storage address of the target source file; The target source file corresponding to the source file storage address is obtained from the source file storage area, and the preview file is generated in real time based on the target source file.

4. The method according to claim 1, characterized in that, After updating the preview file identifier in the source file information, the method further includes: Based on the preview file identifier, the preview file information corresponding to the target source file is recorded; wherein, the preview file status in the preview file information is "in preview". After uploading the preview file to the preview file storage area, determine the preview file storage address and the file size of the preview file; The preview file information is updated using the preview file storage address and the preview file size, and the preview file status in the updated preview file information is "preview complete".

5. The method according to claim 1, characterized in that, Before receiving the file preview request sent by the client, the method further includes: Receive source files uploaded by the client; If it is determined that the source file does not contain duplicates, the source file is uploaded to the source file storage area, and the file size of the source file is determined. If the file size of the source file is greater than or equal to the preview threshold, then the preview file information and source file information corresponding to the source file are recorded, and the preview file corresponding to the source file is generated using an asynchronous preview method; After obtaining the current remaining space in the preview file storage area and the file size of the preview file, the reserved remaining space in the preview file storage area is calculated based on the current remaining space and the file size of the preview file; When the reserved remaining space is greater than or equal to the preset alarm threshold, the preview file is uploaded to the preview file storage area, and the recorded preview file information is updated, with the preview file status in the updated preview file information being "preview complete".

6. The method according to claim 5, characterized in that, Before uploading the preview file to the preview file storage area, the method further includes: When the reserved remaining space is less than the preset alarm threshold, a space release operation is performed on the preview file storage area so that the reserved remaining space of the preview file storage area after space release is greater than or equal to the preset alarm threshold.

7. The method according to claim 6, characterized in that, The step of performing a space release operation on the preview file storage area includes: Obtain information about the first preview file whose preview status is "preview complete" and the first preview file corresponding to the first preview file information; Based on the first preview file information, calculate the upload feature value, preview feature value, and file feature value; The data value of the first preview file is obtained by weighting the upload feature value, the preview feature value, and the file feature value using preset weight parameters. After obtaining the data values ​​of multiple first preview files, they are sorted in descending order of data value to obtain a sorted list including multiple first preview files; Determine at least one preview file to be deleted from the sorted list, and after obtaining the preview file storage address of the at least one preview file to be deleted, delete the at least one preview file to be deleted corresponding to the preview file storage address from the preview file storage area; In this case, the data value of at least one preview file to be deleted is lower than the data value of the remaining preview files in the sorted list.

8. The method according to any one of claims 1 to 7, characterized in that, The preview threshold is estimated in real time based on the performance parameters of the conversion server and the source file information; The method further includes: The conversion server is monitored once per minute to collect its performance parameters, including CPU utilization, remaining memory size, and number of processes. Within a preset time interval, calculate the current average CPU utilization, the current average remaining memory size, and the current average number of processes. Based on the baseline CPU utilization, baseline remaining memory size, and baseline number of processes preset by the conversion server, as well as the current average CPU utilization, current average remaining memory size, and current average number of processes, calculate the difference CPU utilization, difference remaining memory size, and difference number of processes. The pressure value is obtained by weighting the difference CPU utilization, the difference remaining memory size, and the difference number of processes using preset weight parameters. After determining the baseline preview file size based on the source file information, the baseline preview file size and the pressure value are added together to obtain the preview threshold.

9. A file preview device, characterized in that, The file preview device includes a receiving unit, an acquiring unit, and a preview unit, wherein, The receiving unit is configured to receive a file preview request for a source file; wherein the file preview request carries a source file identifier; The acquisition unit is configured to acquire source file information and corresponding preview file information based on the source file identifier. The preview unit is configured to: if the source file has corresponding preview file information, obtain the preview file based on the preview file information; if the source file does not have corresponding preview file information, obtain the source file based on the source file information and synchronously generate a preview file based on the source file; and return the preview file to the client for file preview. The preview unit is further configured to update the preview file identifier in the source file information; wherein the preview file identifier is randomly generated using a snowflake algorithm; based on the source file information, the source file storage address of the target source file is determined, and the target source file corresponding to the source file storage address is obtained from the source file storage area; a key-value pair is formed using the preview file identifier and the target source file, and the key-value pair is placed in an asynchronous preview queue; if the key-value pair is at the head of the asynchronous preview queue, the preview file is generated based on the target source file, and the preview file is uploaded to the preview file storage area.

10. An electronic device, characterized in that, The electronic device includes: a memory and a processor; wherein... The memory is used to store computer programs that can run on the processor; The processor is configured to perform the method as described in any one of claims 1 to 8 when running the computer program.

11. A computer storage medium, characterized in that, The computer storage medium stores a file preview program, which, when executed by at least one processor, implements the method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Display method and device for video preview

    CN106610993A

  • Document online preview method and device

    CN108090078A