WO2023093652A1 - 一种文件预览方法、装置、设备及计算机可读存储介质 - Google Patents

一种文件预览方法、装置、设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2023093652A1
WO2023093652A1 PCT/CN2022/133024 CN2022133024W WO2023093652A1 WO 2023093652 A1 WO2023093652 A1 WO 2023093652A1 CN 2022133024 W CN2022133024 W CN 2022133024W WO 2023093652 A1 WO2023093652 A1 WO 2023093652A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
preview
source file
source
information
Prior art date
Application number
PCT/CN2022/133024
Other languages
English (en)
French (fr)
Inventor
掌静
宋玉龙
张洁
Original Assignee
中移(苏州)软件技术有限公司
中国移动通信集团有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中移(苏州)软件技术有限公司, 中国移动通信集团有限公司 filed Critical 中移(苏州)软件技术有限公司
Publication of WO2023093652A1 publication Critical patent/WO2023093652A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/168Details of user interfaces specifically adapted to file systems, e.g. browsing and visualisation, 2d or 3d GUIs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing

Definitions

  • the present application relates to the field of information technology application technology, and in particular to a file preview method, device, equipment and computer-readable storage medium.
  • common file preview technologies are classified into file synchronous preview technology and file asynchronous preview technology according to implementation methods.
  • the response time and file size show a positive correlation trend, and the problem of long response time in the case of large file preview will be magnified, which will bring users a bad experience;
  • the processing performance has high requirements.
  • the server is prone to preview failures under high load conditions, and even service downtime.
  • the asynchronous preview method it needs to additionally record the preview file.
  • the present application proposes a positioning method, device, equipment and computer-readable storage medium.
  • an embodiment of the present disclosure provides a file preview method, the method is executed by an electronic device, and the method includes:
  • the source file identification obtain the source file information of the target source file
  • the preview file information associated therewith is not detected according to the source file information, determine the file size of the target source file according to the source file information;
  • a preview file is generated by synchronous preview
  • a preview file is generated using an asynchronous preview method
  • an embodiment of the present disclosure provides a file previewing device, the file previewing device includes a receiving unit, an acquiring unit, and a previewing unit, wherein,
  • the receiving unit is configured to receive a file preview request for the source file; wherein, the file preview request carries the source file identifier;
  • the obtaining unit is configured to identify according to the source file; obtain source file information and corresponding preview file information;
  • the preview unit is configured to obtain the preview file according to the preview file information if the source file has corresponding preview file information;
  • the preview unit is further configured to obtain the source file according to the source file information if there is no corresponding preview file information for the source file, and synchronously generate a preview file according to the source file.
  • an embodiment of the present disclosure provides an electronic device, where the electronic device includes: a memory and a processor; wherein,
  • the memory configured to store a computer program executable on the processor
  • the processor is configured to execute the method according to the first aspect when running the computer program.
  • an embodiment of the present disclosure provides a computer-readable storage medium, where a file preview program is stored in the computer-readable storage medium, and when the file preview program is executed by at least one processor, the method described in the first aspect is implemented. method.
  • a file preview method, device, device, and computer-readable storage medium provided by the present application receive a file preview request sent by a client; wherein, the file preview request carries the source file identifier of the target source file; according to the source file identifier, Obtain the source file information of the target source file; if the preview file information associated with it is not detected according to the source file information, determine the file size of the target source file according to the source file information; if the file size of the target source file is less than the preview threshold , the synchronous preview method is used to generate the preview file; if the file size of the target source file is greater than or equal to the preview threshold, the asynchronous preview method is used to generate the preview file; the preview file is returned to the client for file preview.
  • the file preview mode can be dynamically adjusted according to the current server pressure.
  • the synchronous preview pressure is too high, it can be converted to an asynchronous preview mode, which improves the accuracy and response speed of the file preview, thereby improving the efficiency of the file preview.
  • Efficiency because the source file and the preview file are stored separately, the security and reliability of protecting the source file are also improved, and the utilization rate of the storage space is improved at the same time.
  • FIG. 1 is a schematic flowchart of a file preview method provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic flowchart of a source file upload process provided by an embodiment of the present disclosure
  • FIG. 3 is a schematic functional architecture diagram of a file preview method provided by an embodiment of the present disclosure
  • FIG. 4 is a detailed flowchart of a file preview method provided by an embodiment of the present disclosure.
  • FIG. 5 is a detailed flowchart of a source file upload process provided by an embodiment of the present disclosure
  • FIG. 6 is a schematic structural diagram of a file preview device provided by an embodiment of the present disclosure.
  • FIG. 7 is a schematic diagram of the composition and structure of an electronic device provided by an embodiment of the present disclosure.
  • FIG. 8 is a schematic diagram of the composition and structure of another electronic device provided by an embodiment of the present disclosure.
  • references to “some embodiments” describe a subset of all possible embodiments, but it is understood that “some embodiments” may be the same subset or a different subset of all possible embodiments, and Can be combined with each other without conflict.
  • first ⁇ second ⁇ third involved in the embodiments of the present disclosure is only used to distinguish similar objects, and does not represent a specific ordering of objects. Understandably, “first ⁇ second ⁇ Thirdly, the specific order or sequence where permitted is interchangeable such that the embodiments of the disclosure described herein can be practiced in sequences other than those illustrated or described herein.
  • the realization idea of the file preview technology is to convert the source file into a unified target type first, and then render the content information of the target type on the terminal, and finally realize the functional effect that the user can directly preview the file.
  • common file preview technologies are divided into the following two types:
  • File synchronous preview technology After the user initiates a file preview request, the preview file is generated in real time and transmitted to the terminal for content information 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 safer and more reliable.
  • File asynchronous preview technology file conversion is performed when the user uploads the file, and the generated preview file can be obtained after the user initiates a file preview request.
  • the file asynchronous preview technology reduces the time loss caused by generating preview files during the preview process, and has a significant effect of improving the response speed for large file previews.
  • the asynchronous preview method needs to additionally record the preview file, and storing a file requires double the storage space to store the source file and the preview file separately, resulting in a huge redundant space overhead;
  • the source file and the preview file are in the form of electronic files, in the existing asynchronous preview solution, the source file and the preview file will be placed in the same storage area, which brings challenges to the data protection of the source file.
  • an embodiment of the present disclosure provides a file preview method.
  • the basic idea of the method is: receive a file preview request sent by a client; wherein, the file preview request carries the source file identifier of the target source file; , to obtain the source file information of the target source file; in the case that the preview file information associated with it is not detected according to the source file information, determine the file size of the target source file according to the source file information; if the file size of the target source file is smaller than the preview threshold, the synchronous preview method is used to generate the preview file; if the file size of the target source file is greater than or equal to the preview threshold, the asynchronous preview method is used to generate the preview file; the preview file is returned to the client for file preview.
  • the file preview mode can be dynamically adjusted according to the current server pressure.
  • the synchronous preview pressure is too high, it can be converted to an asynchronous preview mode, which improves the accuracy and response speed of the file preview, thereby improving the efficiency of the file preview.
  • Efficiency because the source file and the preview file are stored separately, the security and reliability of protecting the source file are also improved, and the utilization rate of the storage space is improved at the same time.
  • FIG. 1 shows a schematic flowchart of a file preview method provided by an embodiment of the present disclosure.
  • the method may include:
  • S101 Receive a file preview request sent by a client; wherein, the file preview request carries a source file identifier of a target source file.
  • the file preview method provided by the embodiments of the present disclosure can be applied to a device for file preview, or an electronic device integrated with the device.
  • the electronic device may be, for example, a computer, a smart phone, a tablet computer, a notebook computer, a palmtop computer, a personal digital assistant (Personal Digital Assistant, PDA), a navigation device, a server, etc., which are not specifically limited in this embodiment of the present disclosure.
  • PDA Personal Digital Assistant
  • the client can send the file preview to the server when receiving the user's operation to trigger the real-time preview, such as clicking the "real-time preview" button on the client interface. request; 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.
  • S102 Acquire source file information of the target source file according to the source file identifier.
  • the source file information of the target source file can be obtained.
  • the source file information may specifically include a source file identifier, a source file name, a source file type, a source file size, a source file hash (hash) value, and a source file storage address.
  • the source file information can also be expanded and supplemented, and no limitation is set here.
  • the embodiment of the present disclosure may first determine whether there is preview file information associated with the source file information, and combine the current conversion server pressure to further determine which method to implement file preview.
  • a preliminary preview method will be judged on the source file to determine whether it needs to generate a preview file in advance. Therefore, when obtaining the source file information, if no preview file information associated with the source file is detected, it is also necessary to determine the file size of the target source file for the second preview mode judgment, and determine that the final preview mode is synchronous preview Or asynchronous preview.
  • the preview file information associated with it when determining whether the preview file information associated with it is detected according to the source file information, it may be specifically determined whether the preview file identifier in the source file information is empty, and if it is empty, it can be explained that there is no associated preview file information.
  • the preview file associated with the source file that is, the preview file information associated with it has not been detected.
  • the file size of the target source file needs to be determined according to the source file information; if it is not empty, it can indicate that there is a file associated with the source file Preview files.
  • the method may also include:
  • the storage address of the preview file is obtained according to the preview file information
  • the corresponding preview file information if the corresponding preview file information is detected, it can indicate that when the source file is uploaded, the source file is confirmed to be previewed asynchronously.
  • the storage address of the preview file is obtained from the preview file information, and then the preview file corresponding to the storage address of the preview file is obtained from the preview file storage area, and the preview effect is rendered on the client for displaying to the user.
  • the synchronous preview method can be used to directly generate a preview file from the target source file to preview.
  • the synchronous preview method for generating the preview file may include:
  • 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 according to the target source file.
  • a preset software tool such as openoffice software
  • a portable document type such as pdf type
  • S105 If the file size of the target source file is greater than or equal to the preview threshold, generate a preview file in an asynchronous preview manner.
  • the asynchronous preview method can be used at this time, and the preview file is first generated for storage. And preview the file by directly obtaining the preview file from the preview file storage area at an appropriate time.
  • the asynchronous preview method to generate the preview file may include:
  • updating the preview file identifier in the source file information is to update the originally empty preview file identifier in the source file information into a random character string, which is used as the preview file identifier corresponding to the preview file to be generated.
  • key-value pairs are also called attribute-value pairs, which can be expanded according to actual needs.
  • the key-value pair corresponding to the target source file that has received the file preview request may be placed at the front of the asynchronous preview queue, so as not to affect the user experience.
  • the method may further include:
  • the preview file identifier Based on the preview file identifier, record the preview file information corresponding to the target source file; wherein, the preview file status in the preview file information is previewing;
  • the preview file information is updated by using the preview file storage address and the preview file size, and the preview file status in the updated preview file information is preview completion.
  • preview file information may include preview file storage address, preview file size, preview file status, upload times, earliest upload time, last upload time, preview times, earliest preview time, last Preview time. In this way, after the preview file is stored, the above preview file information needs to be updated in time.
  • the target source file can be format-converted (for example, converted to pdf) by using openoffice software, and then the preview file stream can be returned to the client for preview effect rendering.
  • openoffice software is a cross-platform office software suite that is commonly used to handle file conversions.
  • the preview threshold in the embodiments of the present disclosure is estimated in real time based on performance parameters of the conversion server and source file information.
  • the maximum conversion size that the current conversion server can bear is estimated as a whole, so that the synchronous/asynchronous file conversion method can be adaptively selected, and the queue mode is introduced in the asynchronous preview mode to deal with large files and
  • the preview threshold in this embodiment of the present disclosure may be dynamically updated based on the pressure of the conversion server.
  • this embodiment provides a file preview method, by receiving a file preview request sent by the client; wherein, the file preview request carries the source file identifier of the target source file; according to the source file identifier, the source file ID of the target source file is obtained Source file information; if the preview file information associated with it is not detected according to the source file information, determine the file size of the target source file according to the source file information; if the file size of the target source file is smaller than the preview threshold, use synchronous preview If the file size of the target source file is greater than or equal to the preview threshold, asynchronous preview will be used to generate a preview file; the preview file will be returned to the client for file preview.
  • the file preview mode can be dynamically adjusted according to the current server pressure.
  • the synchronous preview pressure is too high, it can be converted to an asynchronous preview mode, which improves the accuracy and response speed of the file preview, thereby improving the efficiency of the file preview.
  • Efficiency because the source file and the preview file are stored separately, the security and reliability of protecting the source file are also improved, and the utilization rate of the storage space is improved at the same time.
  • FIG. 2 shows a schematic flowchart of a file upload process. As shown in Figure 2, the method may include:
  • S201 Receive a source file uploaded by a client.
  • the method may also include:
  • first source file information identical to the first file type and the first file hash value, it is determined that the source file is repeated, and the source file storage address and preview file identifier in the first source file information will be confirmed as the source The storage address of the first source file corresponding to the file and the identifier of the first preview file.
  • the embodiment of the present disclosure uses the source file type and the source file hash value to check whether the source file is duplicated.
  • other content in the source file information can also be used to check for duplicates according to the situation.
  • the premise is The source file information used in the duplicate check is the unique identification of the source file, which does not affect the duplicate check effect.
  • the source file storage address and preview file ID in the source file information can be updated to the source file storage address and preview file ID in the same record. If there is no first source file information that is the same as the first file type and the first file hash value, then it can be explained that there is no duplication of the source file. At this time, the source file needs to be uploaded to the source file storage area and the source file is determined. file size.
  • the file size of the source file is smaller than the preview threshold, it can be explained that when the initial preview method is judged during the source file upload process, the source file is determined to be previewed synchronously. At this time, only the source file information needs to be obtained for subsequent When a file preview request is received, the source file is directly converted into a preview file for preview on the client.
  • the source file information corresponding to the source file needs to be recorded in the preset source file information table; among them, the preview in the source file information
  • the file ID is set to empty, and the source file ID in the source file information is randomly generated by the snowflake algorithm.
  • the preview file information corresponding to the source file needs to be recorded in the preset preview file information table, and the source file corresponding to The source file information is recorded in the preset source file information table; wherein, 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.
  • the file size of the source file is greater than or equal to the preview threshold, it can be explained that after the initial preview method is judged during the source file upload process, it is determined that the source file needs to be previewed asynchronously. At this time, the preview file information corresponding to the source file needs to be recorded and source file information, so that when a corresponding file preview request is subsequently received, the preview file can be directly obtained from the preview file storage area and the file preview can be performed on the client.
  • the current remaining space and the file size of the preview file can be used for differential calculation to obtain the reserved remaining space of the preview file storage area.
  • the size of the preview file is size preview
  • the size of the current remaining space in the acquired preview file storage area is space now
  • the method may further include:
  • the space release operation performed by the preview file storage area may specifically delete the preview files whose preview file status is preview complete and whose data value is low.
  • performing the space release operation on the preview file storage area may include:
  • the first preview file information calculate the upload characteristic value, the preview characteristic value and the file characteristic value
  • 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.
  • the calculation method of data value can be:
  • performing the space release operation on the preview file storage area may also include:
  • 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, delete the preset file corresponding to the second accumulated value, and all files after the preview file in the data value sequence preview files;
  • the cumulative value is the sum of the file sizes of the preview file in the data value sequence and all preview files before it, and 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 accumulated value is ranked behind the preview file corresponding to the first accumulated value.
  • the preview file list obtained according to the data value sorting is [f1,...,fv,fv+1,...,fu], and the file sizes corresponding to the corresponding preview files are accumulated sequentially until the [f1,...,fv] file Accumulated value ⁇ release threshold, and the accumulated value of [f1,...,fv+1] files > release threshold, then you can get the preview file id and preview file storage address corresponding to [fv+1,...,fu], and preview The preview file corresponding to the preview file storage address in the file storage area is deleted.
  • the preview threshold is estimated in real time based on the performance parameters of the conversion server and source file information. Therefore, in some embodiments, for the determination of the preview threshold, the method may further include:
  • the performance parameters can include processor (Center Processing Unit, CPU) utilization, remaining memory size and process quantity;
  • the base preview file size is determined according to the source file information, and the preview threshold is obtained by adding the base preview file size and the pressure value.
  • the average value of pressure within n minutes is calculated every n minutes.
  • you can obtain the CPU utilization rate of each minute from the first minute to the nth minute, represented by c 1 , ..., c n ; the remaining memory size of each minute, represented by m 1 , ..., m n ; The number of processes per minute is represented by t 1 , ..., t n ; in this way, the current average CPU utilization c now (c 1 + ...
  • preview max preview base + p; wherein, preview base is a preset benchmark preview file size.
  • This embodiment provides a file preview method.
  • the current The server pressure dynamically adjusts the file preview mode.
  • the synchronous preview pressure is too high, it can be converted to an asynchronous preview mode, which improves the accuracy and response speed of the file preview, thereby improving the efficiency of the file preview; in addition, because the source file and the preview file are separated. It also improves the security and reliability of protecting source files, while improving the utilization rate of storage space.
  • FIG. 3 shows a schematic diagram of a functional architecture of a file preview method provided by an embodiment of the present disclosure.
  • the method may include an upload module 301, a preview module 302, and a storage module 303; wherein,
  • Upload module 301 provide users with an interface for uploading files; and can check the repeatability of source files.
  • the preview module 302 provides users with an interface-based file preview entry; can also generate preview files; and can check the repeatability of preview files.
  • Storage module 303 divided into three parts: basic information storage area, source file storage area and preview file storage area.
  • the basic information storage area uses a relational database to record source file information and preview file information.
  • the source file storage area and the preview file storage area use the file system to store the source file and the preview file respectively, because the source file needs long-term persistent storage.
  • the source file and the preview file are physically separated to maximize Protect the security and reliability of source files.
  • the preview file storage area is a temporary storage area divided to improve preview performance. Low-value data can be cleared in time through the space release process to improve space utilization.
  • the source file information table stores the basic information and related information of the source file, and the source file information table and the preview file information table are associated through the preview file identification field in the source file information table.
  • the key fields required by the file can be expanded and recorded as required in actual applications.
  • the basic information of the source file may include source file identifier, source file name, source file type, source file size, source file hash value, source file storage address; source file related information may include preview file identifier.
  • the preview file information table stores the basic information and feature information of the preview file.
  • the source file information table and the preview file information table are associated through the preview file identification field in the source file information table.
  • One source file can be associated with at most 1
  • one preview file can be associated with multiple source files.
  • the fields listed above are the key fields necessary for the preview file of this application, and the records can be expanded as required in actual applications.
  • the basic information of the preview file can include preview file identification, preview file storage address, and preview file status
  • the feature information of the preview file can include preview file size, upload times, earliest upload time, last upload time, preview times, earliest preview time , the last preview time.
  • the file conversion method can be dynamically adapted according to the performance of the storage area to improve the overall preview efficiency, reduce redundant file storage through the duplicate detection algorithm, convert the preview features collected in multiple dimensions into quantitative scores, and provide space release. Based on data value, maximize space utilization.
  • the following will describe the implementation details of the three main processes of file preview, file upload, and space release.
  • FIG. 4 shows a detailed flowchart of a file preview method provided by an embodiment of the present disclosure.
  • the method may include:
  • S401 The user initiates a file preview request
  • the source file identifier needs to be carried in the file preview request.
  • the source file information table is jointly searched and the preview file information table is used to obtain source file information and associated preview file information, and the two tables are associated through the preview file identification field.
  • the associated preview file information is queried in S402, it indicates that the corresponding preview file has been generated for the source file, and then go to S404; if the associated preview file information is not queried in S402, it indicates that a preview file needs to be generated, and then go to S406 .
  • the corresponding preview file is obtained from the preview file storage area, and the file stream is returned to the client for rendering the preview effect.
  • S406 Determine whether the size of the source file is smaller than the preview threshold
  • step S407 compare the source file size in the source file information obtained in S402 with the regularly updated preview threshold, if the source file size ⁇ preview threshold, go to step S407, if the source file size ⁇ preview threshold, go to step S408.
  • S407 Generate the preview file asynchronously.
  • the specific implementation method can refer to the following:
  • the preview file ID is the preview file ID in step 1), the number of uploads and the number of previews are both 1, and the earliest upload time, last upload time, earliest preview time, and last preview time are all current time, the preview file status is 1 previewing;
  • step 6) import the preview file that step 4) generates into the preview file storage area, update the preview file size of the corresponding record of the preview file identifier in the preview file information table to be the file size of the file generated in step 4), and the preview file storage address is the preview file The address returned by the storage area, the preview file status is 3 and the preview is complete.
  • the source file is converted into pdf type in real time by using openoffice software, and the file stream is returned to the client for preview effect rendering.
  • FIG. 5 shows a detailed flowchart of a file upload process provided by an embodiment of the present disclosure. As shown in Figure 5, the detailed process may include:
  • the source files are uniformly converted into a pdf file format for file preview, and the source files must be able to be converted into a pdf file format.
  • S502 Determine whether the source file is repeated; the specific implementation method can refer to the following:
  • the MD5 encryption algorithm is a widely used cryptographic hash function, which is simple to implement and can effectively judge complete consistency of the same file;
  • the file system (that is, the database) is a distributed file system, including but not limited to distributed storage fastdfs, data layer server (Team Foundation Server, tfs), through multi-node deployment can effectively deal with high concurrency and massive data storage;
  • preview max preview base + p
  • preview base is the preset benchmark preview file size
  • preview threshold is the source file size that the conversion server can convert in real time within the user's acceptable time maximum value
  • S505 Determine whether the size of the source file is smaller than the preview threshold; the specific implementation method can refer to the following:
  • the preview threshold is set to divert the real-time conversion pressure, and the size of the source file obtained in S502 is compared with the current preview input in S504 Threshold, if the size of the source file 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, and set the preview file identifier in the source file information to be empty, and turn to S506;
  • step 107 If the size of the source file is greater than or equal to the preview threshold, it indicates that the real-time preview takes a long time, and go to step 107.
  • New record in the source file information table set the source file identifier in the source file information as 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.
  • step 1) and step 2) are performed; when the execution of S505 to S506 is completed, because Synchronous preview (there is no preview file in the process), so there is no need to update the preview file information table, so only step 2) can be performed.
  • the asynchronous preview queue is a shunt measure designed to cope with high-load preview situations, so that the conversion server will not be due to a surge The conversion demand is down;
  • openoffice is a cross- The platform's office software suite, commonly used to handle file conversions;
  • S509 Determine whether the size of the remaining preview space space preview is smaller than the alarm threshold space min ; the specific implementation method can refer to the following:
  • the alarm threshold is a preset alarm value of the remaining space of the preview file storage area.
  • 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 as the storage address returned by the file system;
  • the status of the preview file in the preview file information is updated according to the preview file identifier to be 3, preview completed, and the size of the preview file to be size preview .
  • preview files are temporary files generated to improve user experience. Even if all preview files are lost, the function usage should not be affected; and as the frequency of use decreases, the preview file The value of data will gradually decay. Storing a large number of low-value preview files will reduce the utilization rate of storage space and bring redundant storage costs. Therefore, free up space in time and clean up low-value preview files.
  • space release can be triggered in two ways:
  • the monitor configured by the system regularly monitors the current remaining space space now of the preview file storage area. If the current remaining space space now is smaller than the alarm threshold space min , the space release can be triggered.
  • the preview file storage area needs to have sufficient space (capable of storing the current preview file), so it is necessary to compare the size of the preview remaining space space now with the alarm threshold space min .
  • Step 1 Obtain the preview file whose preview file status is 3 preview completed in the preview file information table
  • Step 2 Calculate the data value in turn;
  • the specific implementation method can refer to the following:
  • Step 3 Sort the list of preview files according to the data value from high to low.
  • the list of preview files obtained according to the sorting is [f 1 ,...,f v ,f v+1 ,...,f u ], and the corresponding preview files are accumulated in turn size until the cumulative value of [f 1 ,..., f v ] files ⁇ the release threshold and the cumulative value of [f 1 ,..., f v+1 ] files > the release threshold, and the release threshold is the maximum value of the preset preview file storage area Excellent size;
  • Step 4 Obtain the preview file identifier and preview file storage address corresponding to [f v+1 ,...,f u ], set the preview file status of the record corresponding to the preview file identifier in the preview file information table to 0, and store the preview file in the preview file storage area The preview file corresponding to the preview file storage address is deleted.
  • the conversion server performance parameters collected in S504 are combined with the characteristics of the source file to estimate the maximum conversion size that the current conversion server can withstand, so as to adaptively select synchronous/asynchronous files Conversion mode, and introduce queue mode in asynchronous preview mode to deal with large files and high concurrent preview; data value update mechanism based on multiple features.
  • the data value of the preview file is evaluated as a whole through the three dimensions of upload feature, preview feature, and file feature.
  • the collection parameters of upload feature and preview feature are maintained based on the current operation, so that the data value of the preview file can be based on time, Frequency is constantly self-updating; space release method based on data value.
  • a dual trigger mechanism is added to the space release process to balance the pressure of frequent monitoring and sudden increase in traffic on the conversion server and storage area, evaluate the possibility of reuse of preview files through data value, eliminate low-value preview files, and increase the storage space of preview files utilization rate.
  • the embodiments of the present disclosure can dynamically adjust the file conversion method according to the server pressure, when synchronous preview When the pressure is high, it will automatically switch to asynchronous preview mode, reducing the functional error of preview blocking or even service crash caused by high-concurrency synchronous preview or low-performance server conversion, and improving the correctness and response speed of the overall file preview function; on the other hand, this The disclosed embodiment increases the space release process, evaluates the data value of the preview file according to multiple characteristics and continuously updates it, and uses the data value as a basis to guide the reasonable release of redundant occupation of the preview file storage area, improving space utilization while ensuring high-frequency preview files response speed; on the other hand, the embodiment of the present disclosure also divides the preview file storage area for storage isolation, which protects the security of the source file, and introduces a queue mode so that the preview can still be
  • FIG. 6 shows a schematic structural diagram of a file preview device 60 provided by an embodiment of the present disclosure.
  • the file previewing device 60 may include: a receiving unit 601, an acquiring unit 602, a determining unit 603, and a previewing unit 604; wherein,
  • the receiving unit 601 is configured to receive a file preview request sent by the client; wherein, the file preview request carries the source file identifier of the target source file;
  • the obtaining unit 602 is configured to obtain source file information of the target source file according to the source file identifier
  • the determining unit 603 is configured to determine the file size of the target source file according to the source file information when the associated preview file information is not detected according to the source file information;
  • the preview unit 604 is configured to generate a preview file using a synchronous preview method if the file size of the target source file is smaller than the preview threshold; and if the file size of the target source file is greater than or equal to the preview threshold, then generate a preview file using an asynchronous preview method; and Return the preview file to the client for file preview.
  • the obtaining unit 602 is further configured to obtain the storage address of the preview file according to the preview file information when the associated preview file information is detected according to the source file information;
  • the preview unit 604 is further configured to acquire the preview file corresponding to the preview file storage address from the preview file storage area; and return the preview file to the client for file preview.
  • the preview unit 604 is specifically configured to determine the source file storage address of the target source file according to the source file information; and obtain the target source file corresponding to the source file storage address from the source file storage area, and Source files generate preview files in real time.
  • 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, according to the source file information, determine the source file storage of the target source file Address, 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 If the value pair is at the top 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.
  • the preview unit 604 is specifically configured to record the 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 previewing; and, after uploading the preview file to After the preview file storage area, determine the storage address of the preview file and the file size of the preview file; and update the preview file information using the preview file storage address and the file size of the preview file, and the preview file status in the updated preview file information Done for preview.
  • the file preview device 60 may include an upload unit 605 configured to receive the source file uploaded by the client; 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 the preview threshold, record the preview file information and source file information corresponding to the source file, and generate a preview corresponding to the source file by means of asynchronous preview file; and after obtaining the current remaining space of the preview file storage area and the file size of the preview file, calculate the reserved remaining space of the preview file storage area according to the current remaining space and the file size of the preview file; and when the remaining space is reserved When it 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, and the preview file status in the updated preview file information is preview completed.
  • an upload unit 605 configured to receive the source file uploaded by the client; 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 the preview threshold, record the preview
  • the uploading 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 the preset alarm threshold, so that the reserved space of the preview file storage area obtained after the space is released remains The space is greater than or equal to the preset alarm threshold.
  • the uploading unit 605 is specifically configured to acquire the first preview file information whose preview file status is preview completed and the first preview file corresponding to the first preview file information; and, according to the first preview file information, calculate the upload feature value, preview feature value, and file feature value; and use preset weight parameters to weight the upload feature value, preview feature value, and file feature value to obtain the data value of the first preview file; and, after obtaining multiple first After previewing the data value of the file, sort according to the data value from high to bottom to obtain a sorted list including a plurality of first preview files; and, determine at least one preview file to be deleted from the sorted list, and obtain at least one preview file to be deleted.
  • the preview threshold is estimated in real time based on the performance parameters of the conversion server and source file information; correspondingly, the determination 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 process quantity; and, within a preset time interval, calculate the current average CPU utilization, the current average remaining memory size, and the current average process quantity; and, according to the conversion server preset Set the baseline CPU utilization, baseline remaining memory size, and the number of benchmark processes, as well as the current average CPU utilization, current average remaining memory size, and current average number of processes, and calculate the difference CPU utilization, difference remaining memory size, and difference number of processes ; and, use the preset weight parameters to carry out weighted calculations on the differential CPU utilization rate, the residual memory size of the differential value, and the number of differential processes to obtain a pressure value; And the pressure value is added to get the preview threshold.
  • a "unit” may be a part of a circuit, a part of a processor, a part of a program or software, etc., of course it may also be a module, or it may be non-modular.
  • each component in this embodiment may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software function modules.
  • the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of this embodiment is essentially or It is said that the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product, the computer software product is stored in a storage medium, and includes several instructions to make a computer device (which can It is a personal computer, a server, or a network device, etc.) or a processor (processor) that executes all or part of the steps of the method described in this embodiment.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other various media that can store program codes.
  • this embodiment provides a computer-readable storage medium, and the computer-readable storage medium stores a file preview program, and when the file preview program is executed by at least one processor, the method described in any one of the preceding embodiments is implemented. method steps.
  • an electronic device 70 may include: a communication interface 701 , a memory 702 , and a processor 703 ; each component is coupled together through a bus system 704 .
  • the bus system 704 is used to realize connection and communication between these components.
  • the bus system 704 also includes a power bus, a control bus and a status signal bus.
  • the various buses are labeled as bus system 704 in FIG. 7 .
  • the communication interface 701 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
  • the memory 702 is configured to store computer programs capable of running on the processor 703;
  • the processor 703 is configured to, when running the computer program, execute:
  • the source file identification obtain the source file information of the target source file
  • the preview file information associated therewith is not detected according to the source file information, determine the file size of the target source file according to the source file information;
  • a preview file is generated by synchronous preview
  • a preview file is generated using an asynchronous preview method
  • the memory 702 in the embodiment of the present disclosure may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories.
  • the non-volatile memory can be read-only memory (Read-Only Memory, ROM), programmable read-only memory (Programmable ROM, PROM), erasable programmable read-only memory (Erasable PROM, EPROM), electronically programmable Erase Programmable Read-Only Memory (Electrically EPROM, EEPROM) or Flash.
  • the volatile memory can be Random Access Memory (RAM), which acts as external cache memory.
  • RAM Static Random Access Memory
  • SRAM Static Random Access Memory
  • DRAM Dynamic Random Access Memory
  • Synchronous Dynamic Random Access Memory Synchronous Dynamic Random Access Memory
  • SDRAM double data rate synchronous dynamic random access memory
  • Double Data Rate SDRAM DDRSDRAM
  • ESDRAM enhanced synchronous dynamic random access memory
  • SLDRAM synchronous chain dynamic random access memory
  • Direct Rambus RAM Direct Rambus RAM
  • the processor 703 may be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method may be completed by an integrated logic circuit of hardware in the processor 703 or instructions in the form of software.
  • the above-mentioned processor 703 may be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field Programmable Gate Array
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the methods disclosed in the embodiments of the present disclosure may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory 702, and the processor 703 reads the information in the memory 702, and completes the steps of the above method in combination with its hardware.
  • the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing device (DSP Device, DSPD), programmable Logic device (Programmable Logic Device, PLD), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other devices used to perform the functions described in this application electronic unit or its combination.
  • ASIC Application Specific Integrated Circuits
  • DSP Digital Signal Processing
  • DSP Device digital signal processing device
  • DSPD digital signal processing device
  • PLD programmable Logic Device
  • Field-Programmable Gate Array Field-Programmable Gate Array
  • FPGA Field-Programmable Gate Array
  • the techniques described herein can be implemented through modules (eg, procedures, functions, and so on) that perform the functions described herein.
  • Software codes can be stored in memory and executed by a processor.
  • Memory can be implemented within the processor or external to the processor.
  • the processor 703 is further configured to execute the steps of the method described in any one of the foregoing embodiments when running the computer program.
  • FIG. 8 shows a schematic composition structure diagram of another electronic device 70 provided by an embodiment of the present disclosure.
  • the electronic device 70 may include the file previewing apparatus 60 described in any one of the foregoing embodiments.
  • the file preview request sent by the client is received; wherein, the file preview request carries the source file identifier of the target source file; according to the source file identifier, the source file of the target source file is obtained information; if the associated preview file information is not detected according to the source file information, determine the file size of the target source file according to the source file information; if the file size of the target source file is smaller than the preview threshold, use the synchronous preview method to generate Preview the file; if the file size of the target source file is greater than or equal to the preview threshold, use the asynchronous preview method to generate the preview file; return the preview file to the client for file preview.
  • the file preview mode can be dynamically adjusted according to the current server pressure.
  • the synchronous preview pressure is too high, it can be converted to an asynchronous preview mode, which improves the accuracy and response speed of the file preview, thereby improving the efficiency of the file preview.
  • Efficiency because the source file and the preview file are stored separately, the security and reliability of protecting the source file are also improved, and the utilization rate of the storage space is improved at the same time.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种文件预览方法、装置、设备以及计算机可读存储介质,该方法包括:接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;根据源文件标识,获取目标源文件的源文件信息;在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;将预览文件返回到客户端进行文件预览。这样,能够根据当下服务器压力动态调整文件预览方式,当同步预览压力过大时可转换为异步预览方式,提升了文件预览的准确性和响应速度。

Description

一种文件预览方法、装置、设备及计算机可读存储介质
相关申请的交叉引用
本申请基于申请号为2021114134139、申请日为2021年11月25日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本公开作为参考。
技术领域
本申请涉及信息技术应用技术领域,尤其涉及一种文件预览方法、装置、设备以及计算机可读存储介质。
背景技术
随着大数据时代的发展,越来越多的数据资料以电子文件的形式记录在服务器中,在日常使用中用户需要频繁地查看存储文件的内容信息,为了满足该需求,文件预览技术应运而生。
在相关技术中,按照实现方式分类,常见的文件预览技术分为文件同步预览技术和文件异步预览技术。其中,对于同步预览方式,其响应时间和文件大小呈现正相关趋势,大文件预览情况下响应时间长问题会被放大,给用户带来不佳的使用体验感;但是实时文件转换对转换服务器的处理性能有较高要求,面临高并发的文件转换请求时,服务器在高负载的情况下容易造成预览失败,甚至导致服务宕机。对于异步预览方式,其需要额外记录预览文件,存储一个文件就需要划分双倍的存储空间分别存储源文件和预览文件,造成极大的冗余空间开销;而且因为源文件和预览文件都是电子文件的形式,在现有的异步预览方案中,源文件和预览文件会放在同一存储区中,给源文件的数据保护带来了挑战,同时还降低了存储空间的利用率。
发明内容
本申请提出一种定位方法、装置、设备及计算机可读存储介质。
为达到上述目的,本申请的技术方案是这样实现的:
第一方面,本公开实施例提供了一种文件预览方法,所述方法由电子设备执行,该方法包括:
接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;
根据源文件标识,获取目标源文件的源文件信息;
在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;
若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;
若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;
将预览文件返回到客户端进行文件预览。
第二方面,本公开实施例提供了一种文件预览装置,该文件预览装置包括接收单元、获取单元和预览单元,其中,
接收单元,配置为接收对源文件的文件预览请求;其中,文件预览请求中携带源文件标识;
获取单元,配置为根据源文件标识;获取源文件信息和对应的预览文件信息;
预览单元,配置为若源文件存在对应的预览文件信息,则根据预览文件信息获取预览文件;
预览单元,还配置为若源文件不存在对应的预览文件信息,则根据源文件信息获取源文件,并根据源文件同步生成预览文件。
第三方面,本公开实施例提供了一种电子设备,该电子设备包括:存储器和处理器;其中,
所述存储器,配置为存储能够在所述处理器上运行的计算机程序;
所述处理器,配置为在运行所述计算机程序时,执行如第一方面所述的方法。
第四方面,本公开实施例提供了一种计算机可读存储介质,该计算机可读存储介质存储有文件预览程序,所述文件预览程序被至少一个处理器执行时实现如第一方面所述的方法。
本申请所提供的一种文件预览方法、装置、设备以及计算机可读存储介质,接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;根据源文件标识,获取目标源文件的源文件信息;在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;将预览文件返回到客户端进行文件预览。这样,在文件预览过程中,能够根据当下服务器压力动态调整文件预览方式,当同步预览压力过大时可转换为异步预览方式,提升了文件预览的准确性和响应速度,从而提高了文件预览的效率;另外,由于源文件和预览文件分开存储,还提高了保护源文件的安全性和可靠性,同时提高了存储空间的利用 率。
附图说明
图1为本公开实施例提供的一种文件预览方法的流程示意图;
图2为本公开实施例提供的一种源文件上传过程的流程示意图;
图3为本公开实施例提供的一种文件预览方法的功能架构示意图;
图4为本公开实施例提供的一种文件预览方法的详细流程示意图;
图5为本公开实施例提供的一种源文件上传过程的详细流程示意图;
图6为本公开实施例提供的一种文件预览装置的组成结构示意图;
图7为本公开实施例提供的一种电子设备的组成结构示意图;
图8为本公开实施例提供的另一种电子设备的组成结构示意图。
具体实施方式
为了能够更加详尽地了解本公开实施例的特点与技术内容,下面结合附图对本公开实施例的实现进行详细阐述,所附附图仅供参考说明之用,并非用来限定本公开实施例。
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本公开实施例的目的,不是旨在限制本申请。
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。还需要指出,本公开实施例所涉及的术语“第一\第二\第三”仅是用于区别类似的对象,不代表针对对象的特定排序,可以理解地,“第一\第二\第三”在允许的情况下可以互换特定的顺序或先后次序,以使这里描述的本公开实施例能够以除了在这里图示或描述的以外的顺序实施。
在实际应用中,文件预览技术的实现思路是先将源文件转换为统一的目标类型,再在终端渲染目标类型内容信息,最终实现用户可以直接预览文件的功能效果。按照实现方式分类,常见的文件预览技术分为以下两种:
(1)文件同步预览技术:用户发起文件预览请求后实时生成预览文件,并传输到终端进行内容信息渲染。该技术实现相对简单,而且因为生成后直接返回文件流,不会在服务器中占用额外的存储空间,源文件的持久化也更加安全可靠。
(2)文件异步预览技术:在用户上传文件时就进行文件转换,用户发起文件预览请求后即可获取已生成的预览文件。文件异步预览技术减少了预览 过程中生成预览文件所造成的时间损耗,对于大文件预览情况有明显的响应速度提升效果。
在相关技术中,对于文件同步预览技术而言,目前存在如下问题:同步预览方式中响应时间和文件大小呈现正相关趋势,大文件预览情况下响应时间长问题会被放大,给用户带来不佳的使用体验感;另外,实时文件转换对转换服务器的处理性能有较高要求,面临高并发的文件转换请求时,服务器在高负载的情况下容易造成预览失败,甚至导致服务宕机。
对于文件同步预览技术而言,目前存在如下问题:异步预览方式需要额外记录预览文件,存储一个文件就需要划分双倍的存储空间分别存储源文件和预览文件,造成极大的冗余空间开销;另外,因为源文件和预览文件都是电子文件的形式,在现有的异步预览方案中,源文件和预览文件会放在同一存储区中,给源文件的数据保护带来了挑战。
由此可见,相关技术都对文件预览技术进行了优化,但在时间和空间上不能实现很好的平衡,本公开实施例是为了解决相关技术中因大文件预览和高并发请求造成的预览低效问题,以及因源文件和预览文件统一存储带来的存储低利用率问题。
基于此,本公开实施例提供了一种文件预览方法,该方法的基本思想是:接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;根据源文件标识,获取目标源文件的源文件信息;在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;将预览文件返回到客户端进行文件预览。这样,在文件预览过程中,能够根据当下服务器压力动态调整文件预览方式,当同步预览压力过大时可转换为异步预览方式,提升了文件预览的准确性和响应速度,从而提高了文件预览的效率;另外,由于源文件和预览文件分开存储,还提高了保护源文件的安全性和可靠性,同时提高了存储空间的利用率。
实施例一
本申请的一实施例中,参见图1,其示出了本公开实施例提供的一种文件预览方法的流程示意图。如图1所示,该方法可以包括:
S101:接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识。
需要说明的是,本公开实施例提供的文件预览方法可以应用于进行文件 预览的装置,或者集成有该装置的电子设备。这里,电子设备可以是诸如计算机、智能手机、平板电脑、笔记本电脑、掌上电脑、个人数字助理(Personal Digital Assistant,PDA)、导航装置、服务器等等,本公开实施例对此不作具体限定。
还需要说明的是,如果本公开实施例的电子设备具体是指服务器,那么客户端在接收到用户触发实时预览的操作如点击客户端界面的“实时预览”按钮时,可以向服务器发送文件预览请求;然后服务器接收到该文件预览请求后,还可以获知文件预览请求中携带目标源文件的源文件标识。
S102:根据源文件标识,获取目标源文件的源文件信息。
需要说明的是,根据源文件标识,可以获取到目标源文件的源文件信息。在本公开实施例中,源文件信息具体可以包括源文件标识、源文件名、源文件类型、源文件大小、源文件哈希(hash)值、源文件存储地址。在实际应用中,也可以对源文件信息进行扩展和补充,在此不作任何限定。
还需要说明的是,通常情况下,在接收到用户发送的文件预览请求时,优先采用同步预览,但是由于存在文件过大,或者同时多个文件预览请求的情况,超出了转换服务器的合理负载范围,这时候需要根据文件预览请求中的源文件标识对相应的源文件进行异步预览。
这样,本公开实施例在获取到源文件信息之后,首先可以确定是否存在与该源文件信息关联的预览文件信息,并结合当下转换服务器压力,以便进一步确定采用何种方式实现文件预览。
S103:在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小。
需要说明的是,在源文件上传的过程中,会对源文件进行初步预览方式判断,判断其是否需要预先生成预览文件。因此在获取源文件信息时,如果没有检测到与该源文件具有关联的预览文件信息,那么还需要确定目标源文件的文件大小进行第二次预览方式判断,确定出最终的预览方式为同步预览还是异步预览。
还需要说明的是,在确定根据源文件信息是否检测到与之关联的预览文件信息时,具体可以是判断源文件信息中的预览文件标识是否为空,如果为空,那么可以说明不存在与该源文件关联的预览文件,即未检测到与之关联的预览文件信息,这时候需要根据源文件信息确定目标源文件的文件大小;如果不为空,那么可以说明存在与该源文件关联的预览文件。
在一些实施例中,对于存在与该源文件关联的预览文件的情况,在一些实施例中,该方法还可以包括:
在根据源文件信息检测到与之关联的预览文件信息的情况下,根据预览文件信息获取预览文件存储地址;
从预览文件存储区中获取预览文件存储地址对应的预览文件;
将预览文件返回到客户端进行文件预览。
需要说明的是,在获取源文件信息的过程中,如果检测到与之对应的预览文件信息,那么可以说明在源文件上传的时候,该源文件就被确认需要进行异步预览。这时候从预览文件信息中获取预览文件存储地址,进而从预览文件存储区中获取到该预览文件存储地址对应的预览文件,并在客户端进行预览效果渲染,以便向用户进行展示。
还需要说明的是,获取预览文件的过程,具体可以先通过源文件标识获取到源文件信息,然后根据源文件信息中的预览文件标识获取预览文件信息,最后根据预览文件信息中的预览文件存储地址获取预览文件。
S104:若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件。
需要说明的是,在转换服务器的合理负载范围内,目标源文件的大小并不过大,且没有超出负载的并发文件预览请求时,这时候可以采用同步预览方式,将目标源文件直接生成预览文件进行预览。
在一些实施例中,在目标源文件的文件大小小于预览阈值的情况下,所述利用同步预览方式生成预览文件,可以包括:
根据源文件信息,确定目标源文件的源文件存储地址;
从源文件存储区中获取源文件存储地址对应的目标源文件,并根据目标源文件实时生成预览文件。
在本公开实施例中,在获取到源文件后,然后使用预设软件工具(例如openoffice软件)实时将源文件转成可移植文档类型(例如pdf类型),然后将文件流返回客户端进行预览效果渲染。
S105:若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件。
需要说明的是,在文件预览请求超出转换服务器的合理负载范围,例如目标源文件的大小过大,或者存在高并发文件预览请求时,这时候可以采用异步预览方式,首先生成预览文件进行存储,并在恰当的时间直接从预览文件存储区中获取预览文件的方式进行文件预览。
在一些实施例中,在目标源文件的文件大小大于或等于预览阈值的情况下,所述利用异步预览方式生成预览文件,可以包括:
更新源文件信息中的预览文件标识;其中,预览文件标识是通过雪花算 法随机生成;
根据源文件信息,确定目标源文件的源文件存储地址,并从源文件存储区中获取源文件存储地址对应的目标源文件;
利用预览文件标识和目标源文件组成键值对,并将键值对放入异步预览队列;
若键值对处于异步预览队列的首位,则根据目标源文件生成预览文件,并将预览文件上传至预览文件存储区。
需要说明的是,更新源文件信息中的预览文件标识是将源文件信息中本来为空的预览文件标识更新成一个随机的字符串,作为即将生成的预览文件对应的预览文件标识。
还需要说明的是,键值对又称属性值对,可以根据实际需要进行扩展。在一种具体的实施例中,已经接收到文件预览请求的目标源文件对应的键值对可以排在异步预览队列靠前的位置,以免影响用户使用体验。
在一些实施例中,在一些实施例中,在更新源文件信息中的预览文件标识之后,该方法还可以包括:
基于预览文件标识,记录目标源文件对应的预览文件信息;其中,预览文件信息中的预览文件状态为预览中;
在将预览文件上传至预览文件存储区之后,确定预览文件存储地址以及预览文件的文件大小;
利用预览文件存储地址和预览文件的文件大小对预览文件信息进行更新,且更新后的预览文件信息中的预览文件状态为预览完成。
需要说明的是,在一些具体的实施例中,预览文件信息可以包括预览文件存储地址、预览文件大小、预览文件状态、上传次数、最早上传时间、最后上传时间、预览次数、最早预览时间、最后预览时间。这样,在预览文件存储之后,需要及时将以上预览文件信息进行更新。
S106:将预览文件返回到客户端进行文件预览。
需要说明的是,对于S104和S105中获取的预览文件,具体可以采用openoffice软件将目标源文件进行格式转换(例如转换成pdf类型)后,将预览文件流返回客户端进行预览效果渲染。在这里,openoffice软件是一种跨平台的办公室软件套件,常用来处理文件转换。
还需要说明的是,本公开实施例中的预览阈值是基于转换服务器的性能参数以及源文件信息进行实时估算得到的。这样,根据转换服务器性能参数结合源文件特征整体估算当前转换服务器能够承受的最大转换大小,从而自适应选择同步/异步的文件转换方式,并在异步预览方式中引入队列模式,以 应对大文件和高并发预览情况,即本公开实施例的预览阈值可以是基于转换服务器压力进行动态更新的。
综上可知,本实施例提供了一种文件预览方法,通过接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;根据源文件标识,获取目标源文件的源文件信息;在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;将预览文件返回到客户端进行文件预览。这样,在文件预览过程中,能够根据当下服务器压力动态调整文件预览方式,当同步预览压力过大时可转换为异步预览方式,提升了文件预览的准确性和响应速度,从而提高了文件预览的效率;另外,由于源文件和预览文件分开存储,还提高了保护源文件的安全性和可靠性,同时提高了存储空间的利用率。
实施例二
在接收客户端发送的文件预览请求之前,本公开实施例需要先完成文件上传。参见图2,其示出了一种文件上传过程的流程示意图。如图2所示,该方法可以包括:
S201:接收客户端上传的源文件。
S202:在判断出源文件不存在重复的情况下,将源文件上传至源文件存储区,并确定源文件的文件大小。
需要说明的是,在接收到客户端上传的源文件之后,首先需要判断源文件是否存在重复。
在一些实施例中,关于判断源文件是否存在重复,该方法还可以包括:
获取源文件对应的第一文件类型和第一文件哈希值;
在源文件信息表中查询第一文件类型和第一文件哈希值;
若存在与第一文件类型和第一文件哈希值均相同的第一源文件信息,则确定源文件重复,并将将第一源文件信息中的源文件存储地址和预览文件标识确认为源文件对应的第一源文件存储地址和第一预览文件标识。
需要说明的是,本公开实施例采用源文件类型和源文件哈希值进行源文件是否重复的查询,在实际应用中,也可以根据情况采用源文件信息中的其他内容进行查重操作,前提是查重使用的源文件信息是对该源文件的唯一标识,不影响查重效果即可。
还需要说明的是,如果源文件存在重复,那么可以将源文件信息中的源文件存储地址和预览文件标识更新为相同记录中的源文件存储地址和预览文 件标识。如果不存在与第一文件类型和第一文件哈希值均相同的第一源文件信息,那么可以说明源文件不存在重复,这时候需要将源文件上传至源文件存储区,并确定源文件的文件大小。
S203:若源文件的文件大小小于预览阈值,则记录源文件对应的源文件信息。
需要说明的是,如果源文件的文件大小小于预览阈值,那么可以说明在源文件上传过程中进行初次预览方式判断时,确定该源文件进行同步预览,这时候仅需要获取源文件信息,以便后续在收到文件预览请求的情况下,直接将源文件转换成预览文件在客户端进行预览。
还需要说明的是,对于同步预览而言,后续在接收到文件预览请求的情况下,考虑到服务器的实时压力,这时候还需要对源文件大小和实时预览阈值进行比较,即进行第二次预览方式判断,以便最终确定出该源文件是采用异步预览还是同步预览。
S204:若源文件的文件大小大于或者等于预览阈值,则记录源文件对应的预览文件信息和源文件信息,并利用异步预览方式生成源文件对应的预览文件。
需要说明的是,在源文件上传过程中,如果源文件的文件大小小于预览阈值,那么需要将源文件对应的源文件信息记录到预设源文件信息表中;其中,源文件信息中的预览文件标识设置为空,源文件信息中的源文件标识是通过雪花算法随机生成。
还需要说明的是,在源文件上传过程中,如果源文件的文件大小大于或者等于预览阈值,那么需要将源文件对应的预览文件信息记录到预设预览文件信息表中,以及将源文件对应的源文件信息记录到预设源文件信息表中;其中,预览文件信息中的预览文件标识是通过雪花算法随机生成,源文件信息中的源文件标识是通过雪花算法随机生成。
这样,如果源文件的文件大小大于或者等于预览阈值,那么可以说明在源文件上传过程中进行初次预览方式判断后,确定该源文件需要采用异步预览,这时候需要记录源文件对应的预览文件信息和源文件信息,以便在后续收到对应的文件预览请求时,可直接从预览文件存储区获取到预览文件并在客户端进行文件预览。
S205:在获取到预览文件存储区的当前剩余空间和预览文件的文件大小后,根据当前剩余空间和预览文件的文件大小计算出预览文件存储区的预留剩余空间。
需要说明的是,本公开实施例可以采用当前剩余空间和预览文件的文件 大小进行作差计算,得到预览文件存储区的预留剩余空间。示例性地,预览文件大小为size preview,获取预览文件存储区当前剩余空间大小为space now,那么预留剩余空间大小space preview=space now-size preview
S206:当预留剩余空间大于或等于预设告警阈值时,将预览文件上传至预览文件存储区,并对记录的预览文件信息进行更新,且更新后的预览文件信息中的预览文件状态为预览完成。
需要说明的是,当预留剩余空间小于预设告警阈值时,这时候需要更新预览文件存储区,即将数据价值较低的预览文件进行删除,以为最新的预览文件提供存储空间。在一些实施例中,在将预览文件上传至预览文件存储区之前,该方法还可以包括:
当预留剩余空间小于预设告警阈值时,对预览文件存储区执行空间释放操作,以使得空间释放后得到的预览文件存储区的预留剩余空间大于或等于预设告警阈值。
也就是说,在本公开实施例中,预览文件存储区执行空间释放操作具体可以是,删除掉预览文件状态为预览完成并且数据价值较低的预览文件。
在一些实施例中,所述对预览文件存储区执行空间释放操作,可以包括:
获取预览文件状态为预览完成的第一预览文件信息以及第一预览文件信息对应的第一预览文件;
根据第一预览文件信息,计算上传特征值、预览特征值和文件特征值;
利用预设权重参数对上传特征值、预览特征值和文件特征值进行加权计算,得到第一预览文件的数据价值;
在得到多个第一预览文件的数据价值之后,按照数据价值从高到底顺序进行排序,得到包括多个第一预览文件的排序列表;
从排序列表中确定至少一个待删除预览文件,以及在获取至少一个待删除预览文件的预览文件存储地址后,从预览文件存储区中将预览文件存储地址对应的至少一个待删除预览文件进行删除;
其中,至少一个待删除预览文件的数据价值均低于排序列表中剩余预览文件的数据价值。
在一种具体的实施方式中,根据第一预览文件信息,可以获取到最后上传时间、最早上传时间、当前时间、最后预览时间、最早预览时间、预览次数、预览文件大小等信息。基于此,数据价值的计算方法可以为:
(1)计算上传特征upload=ut×(最后上传时间-最早上传时间)/上传次数+un×(当前时间-最后上传时间),其中,ut和un为预设的权重参数;
(2)计算预览特征pvw=pt×(最后预览时间-最早预览时间)/预览次数+pn×(当前时间-最后预览时间),其中,pt和pn为预设的权重参数;
(3)计算文件特征file=预览文件大小–预览阈值,该预览阈值是实时更新的;
(4)计算数据价值value=vs×file+vu×upload+vp×pvw,其中,vs、vu、vp为预设的权重参数。
在一些实施例中,在一些实施例中,所述对预览文件存储区执行空间释放操作,还可以包括:
将预览文件按照数据价值从高到低排序得到数据价值序列,并将预览文件的大小依次累加得到累加值;
若第一累加值小于或者等于预设释放阈值,且第二累加值大于预设释放阈值,则删除第二累加值对应的预设文件,以及在数据价值序列中排在该预览文件之后的所有预览文件;
其中,累加值为数据价值序列中预览文件与排在其之前的所有预览文件的文件大小之和,第一累加值为数据价值序列中任意一个预览文件对应的累加值;在数据价值序列中,第二累加值对应的预览文件排在第一累加值对应的预览文件的后一个。
示例性地,根据数据价值排序获取的预览文件列表为[f1,…,fv,fv+1,…,fu],依次累加对应的预览文件对应的文件大小,直到[f1,…,fv]文件的累加值≤释放阈值,且[f1,…,fv+1]文件的累加值>释放阈值,那么可以获取[fv+1,…,fu]对应的预览文件id和预览文件存储地址,将预览文件存储区中预览文件存储地址对应的预览文件删除。
在本公开实施例中,预览阈值是基于转换服务器的性能参数以及源文件信息进行实时估算得到的。因此,在一些实施例中,对于预览阈值的确定,该方法还可以包括:
每分钟监听一次转换服务器,采集得到转换服务器的性能参数;其中,性能参数可以包括处理器(Center Processing Unit,CPU)利用率、剩余内存大小和进程数量;
在预设时间间隔内,计算当前平均CPU利用率、当前平均剩余内存大小和当前平均进程数量;
根据转换服务器预设的基准CPU利用率、基准剩余内存大小和基准进程数量以及当前平均CPU利用率、当前平均剩余内存大小和当前平均进程数量,计算差值CPU利用率、差值剩余内存大小和差值进程数量;
利用预设权重参数对差值CPU利用率、差值剩余内存大小和差值进程数 量进行加权计算,得到压力值;
根据源文件信息确定基准预览文件大小,对基准预览文件大小和压力值进行加法计算,得到预览阈值。
示例性地,在获得最新预览阈值时,每隔n分钟计算n分钟内的压力均值。首先,可以获取在第1分钟到第n分钟内,每一分钟的CPU利用率,用c 1、…、c n表示;每一分钟的剩余内存大小,用m 1、…、m n表示;每一分钟的进程数量,用t 1、…、t n表示;这样,可以分别计算得到转换服务器在n分钟内的当前平均CPU利用率c now=(c 1+…+c n)/n、当前平均剩余内存大小m now=(m 1+…+m n)/n、当前平均进程数量t now=(t 1+…+t n)/n;其中,n为大于1的整数。
然后,计算压力值p=i×(c now-c base)+j×(m now-m base)+k×(t now-t base),c base为预设的转换服务器基准CPU利用率,m base为预设的转换服务器基准剩余内存大小,t base为预设的转换服务器基准进程数量,i、j、k为预设的权重参数;
最后,根据公式preview max=preview base+p;计算出当前预览阈值preview max;其中,preview base为预设的基准预览文件大小。
本实施例提供了一种文件预览方法,通过上述实施例,对前述实施例的具体实现进行了详细阐述,从中可以看出,通过前述实施例的技术方案,在文件预览过程中,能够根据当下服务器压力动态调整文件预览方式,当同步预览压力过大时可转换为异步预览方式,提升了文件预览的准确性和响应速度,从而提高了文件预览的效率;另外,由于源文件和预览文件分开存储,还提高了保护源文件的安全性和可靠性,同时提高了存储空间的利用率。
实施例三
基于前述实施例相同的发明构思,参见图3,其示出了本公开实施例提供的一种文件预览方法的功能架构示意图。如图3所示,该方法可以包括上传模块301、预览模块302、存储模块303;其中,
上传模块301:为用户提供界面化的文件上传入口;并能够校验源文件重复性。
预览模块302:为用户提供界面化的文件预览入口;还可生成预览文件;并能够校验预览文件重复性。
存储模块303:分为基础信息存储区、源文件存储区和预览文件存储区三部分。基础信息存储区使用关系型数据库记录源文件信息、预览文件信息。
在存储模块中,源文件存储区和预览文件存储区使用文件系统分别存储源文件和预览文件,因为源文件需要长期持久化存储,此处将源文件和预览文件从物理上隔离开,最大程度保护源文件的安全性和可靠性。预览文件存 储区是为了提升预览性能划分的临时存储区,可以通过空间释放进程及时清除低价值数据,提高空间利用率。
在一些具体的实施例中,数据库设计中,源文件信息表中的内容详见表1所示,预览文件信息表中的内容详见表2所示。
表1
字段名 描述 样例
源文件标识 主键,唯一标识 1354014251905
源文件名 源文件名 上传文件.docx
源文件类型 源文件类型 docx
源文件大小 源文件大小,单位B 1122
源文件hash值 源文件hash值 202dc462c334d9
源文件存储地址 源文件在源文件存储区的存储地址 M00/00/1905.docx
预览文件标识 预览文件信息表的关联字段 1354014251906
如表1所示,源文件信息表存储源文件的基本信息和关联信息,源文件信息表与预览文件信息表通过源文件信息表中的预览文件标识字段进行关联,上述列举字段为本申请源文件必需的关键字段,实际应用中可按需求进行扩展记录。其中,源文件的基本信息可以包括源文件标识、源文件名、源文件类型、源文件大小、源文件hash值、源文件存储地址;源文件的关联信息可以包括预览文件标识。
表2
Figure PCTCN2022133024-appb-000001
Figure PCTCN2022133024-appb-000002
如表2所示,预览文件信息表存储预览文件的基本信息和特征信息,源文件信息表与预览文件信息表通过源文件信息表中的预览文件标识字段进行关联,1个源文件最多关联1个预览文件,1个预览文件可以关联多个源文件。上述列举字段为本申请预览文件必需的关键字段,实际应用中可按需求进行扩展记录。其中,预览文件的基本信息可以包括预览文件标识、预览文件存储地址、预览文件状态;预览文件的特征信息可以包括预览文件大小、上传次数、最早上传时间、最后上传时间、预览次数、最早预览时间、最后预览时间。
在本公开实施例中,可以将根据存储区性能动态适配文件转换方式提升整体预览效率,通过重复检测算法减少冗余文件存储,将多重维度采集的预览特征转换为量化评分,为空间释放提供数据价值依据,最大化空间利用率。以下将从文件预览、文件上传、空间释放三个主流程陈述方案的实现细节。
基于上述实施例中提供的文件预览方法,在一种具体的实施例中,参见图4,其示出了本公开实施例提供的一种文件预览方法的详细流程示意图。如图4所示,该方法可以包括:
S401:用户发起文件预览请求;
其中,文件预览请求中需携带源文件标识。
S402:获取源文件信息及关联的预览文件信息;
需要说明的是,根据S401传入的源文件标识联查源文件信息表和与预览文件信息表获取源文件信息及关联的预览文件信息,两个表通过预览文件标识字段关联。
S403:判断是否已生成预览文件;
需要说明的是,若S402中查询到关联的预览文件信息,表明该源文件已生成对应的预览文件,转S404;若S402中未查询到关联的预览文件信息,表明需要生成预览文件,转S406。
S404:更新预览文件信息表记录;
需要说明的是,根据S402中获取的预览文件信息中的预览文件标识查询预览文件信息表对应记录,更新预览次数=预览次数+1、最后预览时间为当前时间。
S405:获取预览文件;
需要说明的是,根据S402中获取的预览文件信息中的预览文件存储地址,从预览文件存储区中获取对应的预览文件,将文件流返回客户端进行预览效果渲染。
S406:判断源文件大小是否小于预览阈值;
需要说明的是,比较S402中获取的源文件信息中的源文件大小和定时更新的预览阈值,若源文件大小≥预览阈值,转步骤S407,若源文件大小<预览阈值,转步骤S408。
S407:异步生成预览文件。具体实现方法可以参照以下:
1)更新源文件信息表中源文件标识对应记录的预览文件标识为使用雪花算法生成随机数;
2)新增预览文件信息表记录,预览文件标识为步骤1)中的预览文件标识,上传次数和预览次数均为1,最早上传时间、最后上传时间、最早预览时间、最后预览时间均为当前时间,预览文件状态为1预览中;
3)根据S402中获取的源文件信息中的源文件存储地址,从源文件存储区中获取对应的源文件流;
4)组建键值对[预览文件标识,源文件文件流],将键值对放入异步预览队列,若当前键值对为异步预览队列第一条时,使用openoffice将源文件转成pdf类型的预览文件,并将预览文件传入预览文件存储区,记录预览文件存储地址;
5)将步骤4)生成的预览文件流返回客户端进行预览效果渲染;
6)将步骤4)生成的预览文件传入预览文件存储区,更新预览文件信息表中预览文件标识对应记录的预览文件大小为步骤4)中生成文件的文件大小,预览文件存储地址为预览文件存储区返回的地址,预览文件状态为3预览完成。
S408:同步生成预览文件。
需要说明的是,使用openoffice软件实时将源文件转成pdf类型,将文件流返回客户端进行预览效果渲染。
基于上述实施例中提供的文件预览方法,在另一种具体的实施例中,参见图5,其示出了本公开实施例提供的一种文件上传过程的详细流程示意图。如图5所示,该详细流程可以包括:
S501:用户上传源文件;
需要说明的是,本公开实施例将源文件统一转成pdf文件格式进行文件预览,源文件需能转换成pdf文件格式。
S502:判断源文件是否重复;具体实现方法可以参照以下:
1)从源文件中获取文件名、文件类型、文件大小,设置源文件信息中源文件名、源文件类型、源文件大小为上述获取结果;
2)设置源文件信息中的源文件hash值为对源文件的文件流使用MD5加 密算法处理后的计算值,MD5加密算法是一种被广泛使用的密码散列函数,实现简单,能够有效判断相同文件的完整一致性;
3)因为源文件数量较多,根据源文件类型和源文件hash值在源文件信息表中查询是否存在相同记录以快速获取筛选结果;
4)若S502存在相同记录,表明源文件存储区中已存在重复源文件,设置源文件信息中的源文件存储地址和预览文件标识为相同记录中的源文件存储地址和预览文件标识,转S506;
5)若S502不存在相同记录,表明不存在重复源文件,转S503;
S503:源文件上传源文件存储区。
将源文件上传源文件存储区中的文件系统,设置源文件信息中的源文件存储地址为文件系统返回的存储地址。
文件系统(即数据库)是一种分布式文件系统,包含但不限于分布式存储fastdfs、数据层服务器(Team Foundation Server,tfs),通过多节点部署能够有效应对高并发和海量数据的存储情况;
S504:更新预览阈值preview max;具体实现方法可以参照以下:
1)在转换服务器设置监控器每分钟监听一次转换服务器,在高并发、高负载的应用情况下,转换服务器的CPU利用率越高、剩余内存大小越小、进程数量越多,表示转换服务器仍能够处理的文件越少,转换性能越差,因此采集CPU利用率c=[c 1,…,c n]、剩余内存大小m=[m 1,…,m n]、进程数量t=[t 1,…,t n]作为压力指标,其中,n为预设的预览阈值定时执行时长,转换服务器为预览模块中负责则生成预览文件的服务器;
2)每隔n分钟计算n分钟内的压力均值:计算转换服务器n分钟内的平均CPU利用率c now=(c 1+…+c n)/n、当前平均剩余内存大小m now=(m 1+…+m n)/n、当前平均进程数量大小t now=(t 1+…+t n)/n;
3)计算压力值p=i×(c now-c base)+j×(m now-m base)+k×(t now-t base),c base为预设的转换服务器基准CPU利用率,m base为预设的转换服务器基准剩余内存大小,t base为预设的转换服务器基准进程数量,i、j、k为预设的权重参数;
4)计算当前预览阈值preview max,计算公式为:preview max=preview base+p,preview base为预设的基准预览文件大小,预览阈值为转换服务器在用户可接受时间内能够实时转换的源文件大小最大值;
S505:判断源文件大小是否小于预览阈值;具体实现方法可以参照以下:
1)因为在实时转换预览文件过程中,源文件大小和转换服务器压力对预览文件生成时间有着直接影响,所以设置预览阈值分流实时转换压力,比较S502中获取的源文件大小与S504输入的当前预览阈值,若源文件大小小于预 览阈值,表明当前压力下的转换服务器能够在用户可接受时间内实时转换出预览文件,设置源文件信息中的预览文件标识为空,转S506;
2)若源文件大小大于或等于预览阈值,表明实时预览时间较长,转步骤107。
S506:更新预览文件信息表记录,新增源文件信息表记录;具体实现方法可以参照以下:
1)更新预览文件信息表记录:若S502中获取的源文件信息中的预览文件标识不为空,根据预览文件标识更新预览文件信息中对应记录的上传次数=上传次数+1、最后上传时间为当前时间;
2)新增源文件信息表记录:设置源文件信息中的源文件标识为通过雪花算法生成的随机数,将源文件信息作为一条新记录存入源文件信息表中,雪花算法是一种通用的唯一标识生成算法。
需要说明的是,对于S506来说,当执行完S502转S506的情况下,可能需要更新预览文件信息表,所以执行步骤1)和步骤2);当执行完S505转S506的情况下,因为是同步预览(过程中不存在预览文件),所以不需要更新预览文件信息表,因此仅执行步骤2)即可。
S507:新增预览文件信息表记录,新增源文件信息表记录;具体实现方法可以参照以下:
1)新增预览文件信息表记录:设置预览文件信息中的预览文件标识为通过雪花算法生成的随机数,上传次数为1,最早上传时间为当前时间,最后上传时间为当前时间,预览文件状态为1预览中,将预览文件信息作为一条新纪录存入预览文件信息表中;
2)新增源文件信息表记录:设置源文件信息中的源文件标识为通过雪花算法生成的随机数,预览文件标识为步骤1)中设置的预览文件标识,将源文件信息作为一条新记录存入源文件信息表中,到此步骤源文件上传已完成,用户可以根据源文件标识下载源文件,后续为异步预览文件过程。
S508:异步生成预览文件;具体实现方法可以参照以下:
1)组建键值对[预览文件标识,源文件文件流],将键值对放入异步预览队列,异步预览队列是为了应对高负载预览情况设计的分流措施,使得转换服务器不会因为猛增的转换需求宕机;
2)若当前键值对为异步预览队列第一条时,使用openoffice将源文件转成pdf类型后转S508,若当前键值对不是异步预览队列第一条则继续等待,openoffice是一种跨平台的办公室软件套件,常用来处理文件转换;
S509:判断预览剩余空间大小space preview是否小于告警阈值space min;具 体实现方法可以参照以下:
1)计算步骤108.2中生成的预览文件大小size preview,获取预览文件存储区当前剩余空间大小space now,预览剩余空间大小space preview=space now-size preview
2)若space preview<space min,表明当前预览文件存储区空间不足,需清理预览文件存储区,转步骤110,若space preview≥space min,表明当前预览文件存储区仍能继续存储源文件,转步骤111,告警阈值为预设的预览文件存储区剩余空间大小的告警值。
S510:触发空间释放;
需要说明的是,具体流程在S601-S605中详述,此处不赘述;
S511:预览文件上传预览文件存储区;
需要说明的是,将预览文件上传预览文件存储区中的文件系统,设置预览文件信息中的预览文件存储地址为文件系统返回的存储地址;
S512:更新预览文件信息表记录。
需要说明的是,根据预览文件标识更新预览文件信息中预览文件状态为3预览完成、预览文件大小为size preview
与源文件需要长期安全存储的业务需求不同,预览文件是为了提高用户使用感产生的临时文件,即使预览文件全部丢失也不应该对功能使用产生影响;而且随着使用频率的降低,预览文件的数据价值会逐渐衰减,大量存储低价值的预览文件会降低存储空间的利用率,带来冗余的存储成本,因此及时进行空间释放,清理低价值的预览文件。
除此之外,在本公开实施例中,空间释放可以有两种触发方式:
(1)通过系统配置的监控器,定时监测预览文件存储区的当前剩余空间大小space now,如果当前剩余空间大小space now小于告警阈值space min,那么可以触发空间释放。
在这里,空间释放流程定时触发时,比较当前剩余空间大小space now与告警阈值space min。,空间释放流程主动触发时,如S509中,为满足高并发情况,需要使得预览文件存储区空间充足(能够存储当前预览文件),所以需要比较预览剩余空间大小space now与告警阈值space min
(2)通过异步生成预览文件中主动触发空间释放。具体方法可以包括:
步骤1:获取预览文件信息表中预览文件状态为3预览完成的预览文件;
步骤2:依次计算数据价值;具体实现方法可以参照以下:
1)计算上传特征upload=ut×(最后上传时间-最早上传时间)/上传次数+un×(当前时间-最后上传时间),其中,ut和un为预设的权重参数;
2)计算预览特征pvw=pt×(最后预览时间-最早预览时间)/预览次数+pn×(当前时间-最后预览时间),其中,pt和pn为预设的权重参数;
3)计算文件特征file=预览文件大小-更新阈值;
4)计算数据价值value=vs×file+vu×upload+vp×pvw,其中,vs、vu、vp为预设的权重参数。
步骤3:将预览文件列表按照数据价值从高到低排序,根据排序获取的预览文件列表为[f 1,…,f v,f v+1,…,f u],依次累加对应的预览文件大小,直到[f 1,…,f v]文件的累加值≤释放阈值且[f 1,…,f v+1]文件的累加值>释放阈值,释放阈值为预设的预览文件存储区最优大小;
步骤4:获取[f v+1,…,f u]对应的预览文件标识和预览文件存储地址,将预览文件信息表中预览文件标识对应记录的预览文件状态置为0,预览文件存储区中预览文件存储地址对应的预览文件删除。
在本公开实施例中,基于服务器压力的预览阈值动态更新方法,通过S504采集的转换服务器性能参数结合源文件特征整体估算当前转换服务器能够承受的最大转换大小,从而自适应选择同步/异步的文件转换方式,并在异步预览方式中引入队列模式,以应对大文件和高并发预览情况;基于多重特征的数据价值更新机制。在S602中通过上传特征、预览特征、文件特征三重维度整体评估预览文件数据价值,S506、S512、S404中基于当前操作维护上传特征和预览特征的采集参数,使得预览文件的数据价值能够根据时间、频次不断自更新;基于数据价值的空间释放方法。在空间释放流程中加入双重触发机制,平衡频繁监控和突增流量对转换服务器和存储区的压力,通过数据价值评价预览文件的再使用可能性,淘汰低价值预览文件,提高预览文件存储区空间利用率。
通过上述实施例,对前述实施例的具体实现进行了详细阐述,从中可以看出,通过前述实施例的技术方案,一方面,本公开实施例能够根据服务器压力动态调整文件转换方式,当同步预览压力大时自动转为异步预览方式,减少高并发同步预览或低性能服务器转换文件时造成预览阻塞甚至服务崩溃的功能错误,提升了整体文件预览功能的正确性和响应速度;另一方面,本公开实施例增加空间释放流程,根据多重特征评价预览文件的数据价值并不断更新,以数据价值为依据指导预览文件存储区冗余占用的合理释放,提升空间利用率的同时保障了高频预览文件的响应速度;又一方面,本公开实施例还划分了存储隔离的预览文件存储区,保护了源文件的安全性,引入队列模式,使得在高负载或大文件情况下仍能预览成功,在文件预览流程中动态选择预览文件流获取方式,提升了预览方案容错性。
实施例四
基于前述实施例相同的发明构思,参见图6,其示出了本公开实施例提供的一种文件预览装置60的组成结构示意图。如图6所示,该文件预览装置60可以包括:接收单元601、获取单元602、确定单元603和预览单元604;其中,
接收单元601,配置为接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;
获取单元602,配置为根据源文件标识,获取目标源文件的源文件信息;
确定单元603,配置为在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;
预览单元604,配置为若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;以及若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;以及将预览文件返回到客户端进行文件预览。
在一些实施例中,获取单元602,还配置为在根据源文件信息检测到与之关联的预览文件信息的情况下,根据预览文件信息获取预览文件存储地址;
预览单元604,还配置为从预览文件存储区中获取预览文件存储地址对应的预览文件;以及,将预览文件返回到客户端进行文件预览。
在一些实施例中,预览单元604,具体配置为根据源文件信息,确定目标源文件的源文件存储地址;以及,从源文件存储区中获取源文件存储地址对应的目标源文件,并根据目标源文件实时生成预览文件。
在一些实施例中,预览单元604,具体配置为更新源文件信息中的预览文件标识;其中,预览文件标识是通过雪花算法随机生成;以及,根据源文件信息,确定目标源文件的源文件存储地址,并从源文件存储区中获取源文件存储地址对应的目标源文件;以及,利用预览文件标识和目标源文件组成键值对,并将键值对放入异步预览队列;以及,若键值对处于异步预览队列的首位,则根据目标源文件生成预览文件,并将预览文件上传至预览文件存储区。
在一些实施例中,预览单元604,具体配置为基于预览文件标识,记录目标源文件对应的预览文件信息;其中,预览文件信息中的预览文件状态为预览中;以及,在将预览文件上传至预览文件存储区之后,确定预览文件存储地址以及预览文件的文件大小;以及,利用预览文件存储地址和预览文件的文件大小对预览文件信息进行更新,且更新后的预览文件信息中的预览文件状态为预览完成。
在一些实施例中,参见图6,该文件预览装置60可以包括上传单元605,配置为接收客户端上传的源文件;以及在判断出源文件不存在重复的情况下,将源文件上传至源文件存储区,并确定源文件的文件大小;以及若源文件的文件大小大于或者等于预览阈值,则记录源文件对应的预览文件信息和源文件信息,并利用异步预览方式生成源文件对应的预览文件;以及在获取到预览文件存储区的当前剩余空间和预览文件的文件大小后,根据当前剩余空间和预览文件的文件大小计算出预览文件存储区的预留剩余空间;以及当预留剩余空间大于或等于预设告警阈值时,将预览文件上传至预览文件存储区,并对记录的预览文件信息进行更新,且更新后的预览文件信息中的预览文件状态为预览完成。
在一些实施例中,上传单元605,还配置为当预留剩余空间小于预设告警阈值时,对预览文件存储区执行空间释放操作,以使得空间释放后得到的预览文件存储区的预留剩余空间大于或等于预设告警阈值。
在一些实施例中,上传单元605,具体配置为获取预览文件状态为预览完成的第一预览文件信息以及第一预览文件信息对应的第一预览文件;以及,根据第一预览文件信息,计算上传特征值、预览特征值和文件特征值;以及利用预设权重参数对上传特征值、预览特征值和文件特征值进行加权计算,得到第一预览文件的数据价值;以及,在得到多个第一预览文件的数据价值之后,按照数据价值从高到底顺序进行排序,得到包括多个第一预览文件的排序列表;以及,从排序列表中确定至少一个待删除预览文件,以及在获取至少一个待删除预览文件的预览文件存储地址后,从预览文件存储区中将预览文件存储地址对应的至少一个待删除预览文件进行删除;其中,至少一个待删除预览文件的数据价值均低于排序列表中剩余预览文件的数据价值。
在一些实施例中,预览阈值是基于转换服务器的性能参数以及源文件信息进行实时估算得到的;相应的,确定单元603,还配置为每分钟监听一次转换服务器,采集得到转换服务器的性能参数;其中,性能参数可以包括CPU利用率、剩余内存大小和进程数量;以及,在预设时间间隔内,计算当前平均CPU利用率、当前平均剩余内存大小和当前平均进程数量;以及,根据转换服务器预设的基准CPU利用率、基准剩余内存大小和基准进程数量以及当前平均CPU利用率、当前平均剩余内存大小和当前平均进程数量,计算差值CPU利用率、差值剩余内存大小和差值进程数量;以及,利用预设权重参数对差值CPU利用率、差值剩余内存大小和差值进程数量进行加权计算,得到压力值;以及,根据源文件信息确定基准预览文件大小,对基准预览文件大小和压力值进行加法计算,得到预览阈值。
可以理解地,在本实施例中,“单元”可以是部分电路、部分处理器、部分程序或软件等等,当然也可以是模块,还可以是非模块化的。而且在本实施例中的各组成部分可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
所述集成的单元如果以软件功能模块的形式实现并非作为独立的产品进行销售或使用时,可以存储在一个计算机可读取存储介质中,基于这样的理解,本实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或processor(处理器)执行本实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
因此,本实施例提供了一种计算机可读存储介质,该计算机可读存储介质存储有文件预览程序,所述文件预览程序被至少一个处理器执行时实现前述实施例中任一项所述的方法的步骤。
基于上述文件预览装置60的组成以及计算机可读存储介质,参见图7,其示出了本公开实施例提供的电子设备的具体硬件结构示意图。如图7所示,电子设备70可以包括:通信接口701、存储器702和处理器703;各个组件通过总线系统704耦合在一起。可理解,总线系统704用于实现这些组件之间的连接通信。总线系统704除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图7中将各种总线都标为总线系统704。其中,通信接口701,用于在与其他外部网元之间进行收发信息过程中,信号的接收和发送;
存储器702,配置为存储能够在处理器703上运行的计算机程序;
处理器703,配置为在运行所述计算机程序时,执行:
接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;
根据源文件标识,获取目标源文件的源文件信息;
在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;
若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;
若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;
将预览文件返回到客户端进行文件预览。
可以理解,本公开实施例中的存储器702可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步链动态随机存取存储器(Synchronous link DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。本文描述的系统和方法的存储器702旨在包括但不限于这些和任意其它适合类型的存储器。
而处理器703可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器703中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器703可以是通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本公开实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本公开实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器702,处理器703读取存储器702中的信息,结合其硬件完成上述方法的步骤。
可以理解的是,本文描述的这些实施例可以用硬件、软件、固件、中间件、微码或其组合来实现。对于硬件实现,处理单元可以实现在一个或多个专用集成电路(Application Specific Integrated Circuits,ASIC)、数字信号处理 器(Digital Signal Processing,DSP)、数字信号处理设备(DSP Device,DSPD)、可编程逻辑设备(Programmable Logic Device,PLD)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、通用处理器、控制器、微控制器、微处理器、用于执行本申请所述功能的其它电子单元或其组合中。
对于软件实现,可通过执行本文所述功能的模块(例如过程、函数等)来实现本文所述的技术。软件代码可存储在存储器中并通过处理器执行。存储器可以在处理器中或在处理器外部实现。
可选地,作为另一个实施例,处理器703还配置为在运行所述计算机程序时,执行前述实施例中任一项所述的方法的步骤。
基于上述文件预览装置60的组成以及计算机可读存储介质,参见图8,其示出了本公开实施例提供的另一种电子设备70的组成结构示意图。如图8所示,该电子设备70可以包括前述实施例中任一项所述的文件预览装置60。
在本公开实施例中,对于电子设备70而言,接收客户端发送的文件预览请求;其中,文件预览请求中携带目标源文件的源文件标识;根据源文件标识,获取目标源文件的源文件信息;在根据源文件信息未检测到与之关联的预览文件信息的情况下,根据源文件信息确定目标源文件的文件大小;若目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;若目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;将预览文件返回到客户端进行文件预览。这样,在文件预览过程中,能够根据当下服务器压力动态调整文件预览方式,当同步预览压力过大时可转换为异步预览方式,提升了文件预览的准确性和响应速度,从而提高了文件预览的效率;另外,由于源文件和预览文件分开存储,还提高了保护源文件的安全性和可靠性,同时提高了存储空间的利用率。
需要说明的是,在本申请中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
上述本公开实施例序号仅仅为了描述,不代表实施例的优劣。
本申请所提供的几个方法实施例中所揭露的方法,在不冲突的情况下可以任意组合,得到新的方法实施例。
本申请所提供的几个产品实施例中所揭露的特征,在不冲突的情况下 可以任意组合,得到新的产品实施例。
本申请所提供的几个方法或设备实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的方法实施例或设备实施例。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (12)

  1. 一种文件预览方法,其中,所述方法包括:
    接收客户端发送的文件预览请求;其中,所述文件预览请求中携带目标源文件的源文件标识;
    根据所述源文件标识,获取所述目标源文件的源文件信息;
    在根据所述源文件信息未检测到与之关联的预览文件信息的情况下,根据所述源文件信息确定所述目标源文件的文件大小;
    若所述目标源文件的文件大小小于预览阈值,则利用同步预览方式生成预览文件;
    若所述目标源文件的文件大小大于或等于预览阈值,则利用异步预览方式生成预览文件;
    将所述预览文件返回到所述客户端进行文件预览。
  2. 根据权利要求1所述的方法,其中,所述方法还包括:
    在根据所述源文件信息检测到与之关联的预览文件信息的情况下,根据所述预览文件信息获取预览文件存储地址;
    从预览文件存储区中获取所述预览文件存储地址对应的预览文件;
    将所述预览文件返回到所述客户端进行文件预览。
  3. 根据权利要求1所述的方法,其中,在所述目标源文件的文件大小小于预览阈值的情况下,所述利用同步预览方式生成预览文件,包括:
    根据所述源文件信息,确定所述目标源文件的源文件存储地址;
    从源文件存储区中获取所述源文件存储地址对应的所述目标源文件,并根据所述目标源文件实时生成所述预览文件。
  4. 根据权利要求1所述的方法,其中,在所述目标源文件的文件大小大于或等于预览阈值的情况下,所述利用异步预览方式生成预览文件,包括:
    更新所述源文件信息中的预览文件标识;其中,所述预览文件标识是通 过雪花算法随机生成;
    根据所述源文件信息,确定所述目标源文件的源文件存储地址,并从源文件存储区中获取所述源文件存储地址对应的所述目标源文件;
    利用所述预览文件标识和所述目标源文件组成键值对,并将所述键值对放入异步预览队列;
    若所述键值对处于所述异步预览队列的首位,则根据所述目标源文件生成所述预览文件,并将所述预览文件上传至预览文件存储区。
  5. 根据权利要求4所述的方法,其中,在所述更新所述源文件信息中的预览文件标识之后,所述方法还包括:
    基于所述预览文件标识,记录所述目标源文件对应的预览文件信息;其中,所述预览文件信息中的预览文件状态为预览中;
    在将所述预览文件上传至预览文件存储区之后,确定预览文件存储地址以及所述预览文件的文件大小;
    利用所述预览文件存储地址和所述预览文件的文件大小对所述预览文件信息进行更新,且更新后的所述预览文件信息中的预览文件状态为预览完成。
  6. 根据权利要求1所述的方法,其中,在所述接收客户端发送的文件预览请求之前,所述方法还包括:
    接收客户端上传的源文件;
    在判断出所述源文件不存在重复的情况下,将所述源文件上传至源文件存储区,并确定所述源文件的文件大小;
    若所述源文件的文件大小大于或者等于预览阈值,则记录所述源文件对应的预览文件信息和源文件信息,并利用异步预览方式生成所述源文件对应的预览文件;
    在获取到预览文件存储区的当前剩余空间和所述预览文件的文件大小后,根据所述当前剩余空间和所述预览文件的文件大小计算出所述预览文件存储区的预留剩余空间;
    当所述预留剩余空间大于或等于预设告警阈值时,将所述预览文件上传至所述预览文件存储区,并对所述记录的预览文件信息进行更新,且更新后的所述预览文件信息中的预览文件状态为预览完成。
  7. 根据权利要求6所述的方法,其中,在所述将所述预览文件上传至所述预览文件存储区之前,所述方法还包括:
    当所述预留剩余空间小于预设告警阈值时,对所述预览文件存储区执行空间释放操作,以使得空间释放后得到的所述预览文件存储区的预留剩余空间大于或等于预设告警阈值。
  8. 根据权利要求7所述的方法,其中,所述对所述预览文件存储区执行空间释放操作,包括:
    获取预览文件状态为预览完成的第一预览文件信息以及所述第一预览文件信息对应的第一预览文件;
    根据所述第一预览文件信息,计算上传特征值、预览特征值和文件特征值;
    利用预设权重参数对所述上传特征值、所述预览特征值和所述文件特征值进行加权计算,得到所述第一预览文件的数据价值;
    在得到多个所述第一预览文件的数据价值之后,按照数据价值从高到底顺序进行排序,得到包括多个所述第一预览文件的排序列表;
    从所述排序列表中确定至少一个待删除预览文件,以及在获取所述至少一个待删除预览文件的预览文件存储地址后,从所述预览文件存储区中将所述预览文件存储地址对应的所述至少一个待删除预览文件进行删除;
    其中,所述至少一个待删除预览文件的数据价值均低于所述排序列表中剩余预览文件的数据价值。
  9. 根据权利要求1至8任一项所述的方法,其中,所述预览阈值是基于转换服务器的性能参数以及源文件信息进行实时估算得到的;
    所述方法还包括:
    每分钟监听一次所述转换服务器,采集得到所述转换服务器的性能参数;其中,所述性能参数包括CPU利用率、剩余内存大小和进程数量;
    在预设时间间隔内,计算当前平均CPU利用率、当前平均剩余内存大小和当前平均进程数量;
    根据所述转换服务器预设的基准CPU利用率、基准剩余内存大小和基准进程数量以及所述当前平均CPU利用率、所述当前平均剩余内存大小和所述当前平均进程数量,计算差值CPU利用率、差值剩余内存大小和差值进程数量;
    利用预设权重参数对所述差值CPU利用率、所述差值剩余内存大小和所述差值进程数量进行加权计算,得到压力值;
    在根据所述源文件信息确定基准预览文件大小后,对所述基准预览文件大小和所述压力值进行加法计算,得到所述预览阈值。
  10. 一种文件预览装置,其中,所述文件预览装置包括接收单元、获取单元和预览单元,其中,
    所述接收单元,配置为接收对源文件的文件预览请求;其中,所述文件预览请求中携带源文件标识;
    所述获取单元,配置为根据所述源文件标识;获取源文件信息和对应的预览文件信息;
    所述预览单元,配置为若所述源文件存在对应的预览文件信息,则根据预览文件信息获取所述预览文件;以及若所述源文件不存在对应的预览文件信息,则根据源文件信息获取所述源文件,并根据所述源文件同步生成预览文件;以及将所述预览文件返回到所述客户端进行文件预览。
  11. 一种电子设备,其中,所述电子设备包括:存储器和处理器;其中,
    所述存储器,配置为存储能够在所述处理器上运行的计算机程序;
    所述处理器,配置为在运行所述计算机程序时,执行如权利要求1至9任一项所述的方法。
  12. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有文件预览程序,所述文件预览程序被至少一个处理器执行时实现如权利要求1至9任一项所述的方法。
PCT/CN2022/133024 2021-11-25 2022-11-18 一种文件预览方法、装置、设备及计算机可读存储介质 WO2023093652A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111413413.9 2021-11-25
CN202111413413.9A CN116166619A (zh) 2021-11-25 2021-11-25 一种文件预览方法、装置、设备以及计算机存储介质

Publications (1)

Publication Number Publication Date
WO2023093652A1 true WO2023093652A1 (zh) 2023-06-01

Family

ID=86415048

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/133024 WO2023093652A1 (zh) 2021-11-25 2022-11-18 一种文件预览方法、装置、设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN116166619A (zh)
WO (1) WO2023093652A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130061136A1 (en) * 2010-03-09 2013-03-07 Olivier Cadou Method and system for the remote control of a display screen
CN103942344A (zh) * 2014-05-12 2014-07-23 深圳市中博科创信息技术有限公司 一种预览文件的方法及文件处理系统
CN106909627A (zh) * 2017-01-22 2017-06-30 北京奇艺世纪科技有限公司 一种内容加载方法、装置和移动设备
US20170300458A1 (en) * 2015-08-06 2017-10-19 Dropbox, Inc. Embedding Dynamic Content Item Preview

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130061136A1 (en) * 2010-03-09 2013-03-07 Olivier Cadou Method and system for the remote control of a display screen
CN103942344A (zh) * 2014-05-12 2014-07-23 深圳市中博科创信息技术有限公司 一种预览文件的方法及文件处理系统
US20170300458A1 (en) * 2015-08-06 2017-10-19 Dropbox, Inc. Embedding Dynamic Content Item Preview
CN106909627A (zh) * 2017-01-22 2017-06-30 北京奇艺世纪科技有限公司 一种内容加载方法、装置和移动设备

Also Published As

Publication number Publication date
CN116166619A (zh) 2023-05-26

Similar Documents

Publication Publication Date Title
US11995186B2 (en) Ransomware attack onset detection
US10228851B2 (en) Cluster storage using subsegmenting for efficient storage
TWI790550B (zh) 縮減機率篩選查詢延時
US8756238B2 (en) Index searching using a bloom filter
CN103098035B (zh) 存储系统
US9886464B2 (en) Versioned bloom filter
CN110826594B (zh) 一种轨迹聚类的方法、设备及存储介质
US8170987B2 (en) Methods, systems and computer program products for automatically identifying and backing up user device content
CN104584524B (zh) 聚合中介系统中的数据
US8214411B2 (en) Atomic deletion of database data categories
WO2021068567A1 (zh) 区块链的区块分发方法、装置、计算机设备和存储介质
US20200349113A1 (en) File storage method, deletion method, server and storage medium
CN102819586A (zh) 一种基于高速缓存的url分类方法和设备
CN111443867B (zh) 一种数据存储方法、装置、设备及存储介质
CN109597574B (zh) 分布式数据存储方法、服务器及可读存储介质
US20120072394A1 (en) Determining database record content changes
WO2023093652A1 (zh) 一种文件预览方法、装置、设备及计算机可读存储介质
US20170316024A1 (en) Extended attribute storage
US9483560B2 (en) Data analysis control
US9747299B2 (en) Heterogeneous storing server and file storing method thereof
US20200142591A1 (en) Snapshot managing system
CN111611336B (zh) 终端数据处理系统
CN117135077A (zh) 虚拟地址访问故障处理方法、装置和计算机设备
US20210011826A1 (en) Flattened Historical Material Extracts
CN117914537A (zh) 恶意节点识别方法、装置、计算机设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22897735

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE