Mail attachment compression method and device, computer equipment and readable storage medium

By splitting and compressing file elements in email attachments, the problem of low compression efficiency caused by low repetition rate of file elements is solved, and large files are effectively compressed and successfully sent.

CN118585501APending Publication Date: 2024-09-03PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410721544.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

In the existing technology, the low repetition rate of file elements results in low compression efficiency, resulting in large files that cannot be successfully sent in email attachments because the compressed file size exceeds the specified size.

Method used

By obtaining multiple file elements of the file to be compressed, splitting them into multiple element sets, performing file compression on these element sets, generating compressed data and compression header information, and combining them into a compressed file for sending.

Benefits of technology

The compression ratio of large files is improved, so that the compressed file size meets the specified size, and the success rate of sending email attachments is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585501A
    Figure CN118585501A
Patent Text Reader

Abstract

The invention discloses an email attachment compression method and device, computer equipment and a readable storage medium, relates to the technical field of Internet, and can improve the compression ratio of a large email attachment by improving the compression ratio of each element set, so that the file size after the large email attachment is compressed can meet the specified size. And the sending success rate of the large mail attachment is improved. The method comprises the following steps: obtaining a to-be-compressed file, and analyzing the to-be-compressed file to obtain various file elements forming the to-be-compressed file; according to the multiple file elements, the to-be-compressed file is split into multiple element sets, and each element set records the element content of one file element; and simultaneously performing file compression on the plurality of element sets to obtain compressed data, combining the compressed data and the compression head information into a compressed file, and sending the compressed file to a mail receiver.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a method, device, computer equipment and readable storage medium for compressing email attachments. Background Art

[0002] With the continuous development of Internet technology, in the daily work scenarios of Internet companies, employees usually send work materials to email recipients in the form of email attachments. However, email services limit the size of attachments, making some attachments with too much data unable to be sent successfully.

[0003] In the related art, the sender usually sets a fixed file size, splits the large file in the attachment multiple times according to the file size, and then splits the large attachment into multiple small files whose file sizes are not larger than the fixed file size for compression, and then sends the compressed multiple files as attachments to multiple emails to the receiver. However, there may be multiple types of file elements in the small file, such as numbers, text characters, special symbols, etc. The repetition rate of file elements is low, which makes the compression ratio low in the process of compressing small files, resulting in the compressed file size still exceeding the specified size, thereby affecting the success rate of sending large files. Summary of the invention

[0004] In view of this, the present application provides a method, apparatus, computer device and readable storage medium for compressing email attachments, the main purpose of which is to solve the problem that the current file element repetition rate is low, resulting in low compression in the process of compressing small files, causing the compressed file size to still exceed the specified size, thereby affecting the transmission efficiency of large files.

[0005] According to the first aspect of the present application, a method for compressing an email attachment is provided, the method comprising:

[0006] Obtaining a file to be compressed and performing file parsing to obtain multiple file elements constituting the file to be compressed;

[0007] According to the multiple file elements, split the to-be-compressed file into multiple element sets, wherein each element set records the element content of one file element;

[0008] At the same time, the plurality of element sets are compressed to obtain compressed data, and the compressed data is combined with the compression header information into a compressed file and sent to the email recipient.

[0009] Optionally, before obtaining the file to be compressed and performing file parsing, the method further includes:

[0010] Reading all the attached files of the mails to be sent, and determining the occupied space of each of the attached files of the mails to be sent, to obtain the total occupied space corresponding to all the mails to be sent;

[0011] Each occupied space is compared with a preset occupied space threshold one by one, and the attached files whose occupied space is greater than the preset occupied space threshold are determined as the files to be compressed.

[0012] Optionally, splitting the to-be-compressed file into multiple element sets according to the multiple file elements includes:

[0013] For each file element among the multiple file elements, traverse the to-be-compressed file, and determine the element content corresponding to the file element in the to-be-compressed file;

[0014] Writing the element content into a specified set and associating the specified set with the file element to obtain an element set of the file element;

[0015] An element set is created for each file element to obtain the multiple element sets.

[0016] Optionally, after writing the element content into a specified set and associating the specified set with the file element to obtain the element set of the file element, the method further includes:

[0017] For element content corresponding to each file element, determining location information of the element content in the file to be compressed;

[0018] The position information is recorded in a split information table, where the split information table is used to record the position information of each element content corresponding to the file to be compressed.

[0019] Optionally, the simultaneously performing file compression on the multiple element sets to obtain compressed data includes:

[0020] According to the compression encoding mode corresponding to each file element, the element set associated with each file element is compressed and encoded to obtain a compressed block corresponding to each file element;

[0021] The split information table is read, and the split information table is merged with the compressed blocks corresponding to each of the file elements to obtain the compressed data.

[0022] Optionally, before combining the compressed data and the compressed header information into a compressed file and sending the compressed file to the email recipient, the method further includes:

[0023] Determine the file name of the to-be-compressed file and the initial occupied space of the to-be-compressed file, write the file name and the initial occupied space into a compression information table, and the compression information table is used to generate the compression header information;

[0024] Identifying the compressed data, determining the target occupied space of the to-be-compressed file after compression, and writing the target occupied space into the compression information table;

[0025] The file name, the initial occupied space and the target occupied space recorded in the compression information table are converted into a string type to obtain the compression header information.

[0026] Optionally, sending the compressed file to an email recipient includes:

[0027] querying the occupied space of the compressed file and a preset occupied space threshold, and comparing the occupied space with the preset occupied space threshold;

[0028] When the comparison result indicates that the occupied space is less than or equal to the preset occupied space, the compressed file is sent to the email recipient as an attached file of the email, so that the email recipient can restore the file to be compressed according to the split information table in the compressed file.

[0029] According to a second aspect of the present application, a mail attachment compression device is provided, the device comprising:

[0030] An acquisition module, used for acquiring a file to be compressed, performing file parsing, and obtaining a plurality of file elements constituting the file to be compressed;

[0031] A splitting module, used for splitting the to-be-compressed file into a plurality of element sets according to the plurality of file elements, wherein each element set records the element content of a file element;

[0032] The compression module is used to simultaneously perform file compression on the multiple element sets to obtain compressed data, and to combine the compressed data with compression header information into a compressed file and send it to the email recipient.

[0033] Optionally, the device further comprises:

[0034] A reading module, used to read all the attached files of the mails to be sent, and determine the occupied space of each attached file of the mails to be sent, so as to obtain the total occupied space corresponding to all the mails to be sent;

[0035] The comparison module is used to compare each occupied space with a preset occupied space threshold one by one, and determine the attached files whose occupied space is greater than the preset occupied space threshold as the files to be compressed.

[0036] Optionally, the splitting module is used to traverse the file to be compressed for each file element among the multiple file elements, determine the element content corresponding to the file element in the file to be compressed; write the element content into a specified set and associate the specified set with the file element to obtain an element set of the file element; create an element set for each file element to obtain the multiple element sets.

[0037] Optionally, the splitting module is also used to determine the position information of the element content corresponding to each file element in the file to be compressed; and record the position information in a splitting information table, wherein the splitting information table is used to record the position information of each element content corresponding to the file to be compressed.

[0038] Optionally, the compression module is used to compress and encode the element set associated with each file element according to the compression encoding method corresponding to each file element, so as to obtain a compressed block corresponding to each file element; read the split information table, and merge the split information table with the compressed block corresponding to each file element to obtain the compressed data.

[0039] Optionally, the device further comprises:

[0040] a determination module, used to determine the file name of the to-be-compressed file and the initial occupied space of the to-be-compressed file, and write the file name and the initial occupied space into a compression information table, wherein the compression information table is used to generate the compression header information;

[0041] an identification module, used for identifying the compressed data, determining the target occupied space of the to-be-compressed file after compression, and writing the target occupied space into the compression information table;

[0042] The conversion module is used to convert the file name, initial occupied space and target occupied space recorded in the compression information table into a string type to obtain the compression header information.

[0043] Optionally, the compression module is used to query the occupied space of the compressed file and a preset occupied space threshold, and compare the occupied space with the preset occupied space threshold; when the comparison result indicates that the occupied space is less than or equal to the preset occupied space, the compressed file is sent as an attached file of the email to the email recipient, so that the email recipient can restore the file to be compressed according to the split information table in the compressed file.

[0044] According to a third aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.

[0045] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.

[0046] By means of the above technical scheme, the present application provides a method, device, computer equipment and readable storage medium for compressing an email attachment. The present application first obtains a file to be compressed for file parsing to obtain a plurality of file elements constituting the file to be compressed. Then, according to the plurality of file elements, the file to be compressed is split into a plurality of element sets. Finally, the plurality of element sets are simultaneously compressed to obtain compressed data, and the compressed data is combined with the compression header information into a compressed file and sent to the email recipient. When the embodiment of the present application compresses the split element set, because the element types in each element set are consistent, the element content repetition rate is high, which can improve the compression ratio of each element set and thus improve the compression ratio of the large file, so that the file size of the large file after compression can meet the specified size, thereby improving the success rate of sending the email attachment.

[0047] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0049] Figure 1 A schematic diagram of a method for compressing email attachments provided in an embodiment of the present application is shown;

[0050] Figure 2 A schematic diagram of a method for compressing email attachments provided in an embodiment of the present application is shown;

[0051] Figure 3 A schematic diagram of the structure of a mail attachment compression device provided in an embodiment of the present application is shown;

[0052] Figure 4A schematic diagram of the structure of a mail attachment compression device provided in an embodiment of the present application is shown;

[0053] Figure 5 A schematic diagram of the structure of a mail attachment compression device provided in an embodiment of the present application is shown;

[0054] Figure 6 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0055] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0056] With the continuous development of Internet technology, in the daily work scenarios of Internet companies, enterprise employees usually send work materials to the email recipient in the form of email attachments. However, the email service limits the size of the attachment, so that some attachments with too much data cannot be sent successfully. At present, the sender usually sets a fixed file size, divides the large file in the attachment multiple times according to the file size, and then splits the large attachment into multiple small files with a file size not greater than the fixed file size for compression, and then sends the compressed multiple files as attachments of multiple emails to the recipient. There may be multiple types of file elements in the small file, such as numbers, text characters, special symbols, etc. The repetition rate of the file elements is low, so that the compression is relatively low in the process of compressing small files, resulting in the compressed file size still exceeding the specified size, thereby affecting the success rate of sending large files. Therefore, the present application provides a method for compressing email attachments, first obtaining a file to be compressed for file parsing, and obtaining multiple file elements constituting the file to be compressed. Then, according to the multiple file elements, the file to be compressed is split into multiple element sets. Finally, the multiple element sets are compressed at the same time to obtain compressed data, and the compressed data and the compression header information are combined into a compressed file and sent to the email recipient. When compressing the split element set, the embodiment of the present application has a high repetition rate of element content because the element types in each element set are consistent, which can improve the compression ratio of each element set and thus improve the compression ratio of large files, so that the file size of the large file after compression can meet the specified size, thereby improving the success rate of sending email attachments.

[0057] The present application embodiment provides a method for compressing email attachments, such as Figure 1 As shown, the method includes:

[0058] 101. Obtain a file to be compressed and perform file parsing to obtain multiple file elements constituting the file to be compressed.

[0059] Among them, the file element is used to indicate all types of elements that make up the file to be compressed, including numbers, text characters, special symbols, etc. This application does not specifically limit the specific types of file elements.

[0060] Specifically, the method provided in the embodiment of the present application can be applied to a file compression system, where the file compression system determines, among all the attached files to be sent, the attachments to be sent whose occupied space size is greater than a preset occupied space threshold as the files to be compressed. Then, the files to be compressed are parsed to identify the file elements therefrom, until the files to be compressed are traversed to obtain the multiple file elements constituting the files to be compressed.

[0061] 102. Split the file to be compressed into multiple element sets according to multiple file elements, wherein each element set records element content of one file element.

[0062] Specifically, the file compression system may first select a file element, and then traverse the entire file to be compressed, extract the element content corresponding to the file element, and write it into the corresponding element set. It should be noted that the file compression system may extract the element content corresponding to at least one file element from the file to be compressed. Furthermore, for multiple file elements, the element content is extracted for each file element one by one and written into the element set, so as to obtain multiple element sets corresponding to multiple file elements.

[0063] 103. Perform file compression on multiple element sets at the same time to obtain compressed data, and combine the compressed data with compression header information into a compressed file and send it to an email recipient.

[0064] The compression header information specifically consists of a string type and two UInt32 (4-byte) integers, which respectively represent the file name of the to-be-compressed file and the size of the space occupied by the to-be-compressed file after compression and the size of the space occupied by the to-be-compressed file before compression.

[0065] Specifically, the file compression system compresses different element sets concurrently, and then merges the results obtained after the compression of different element sets to obtain compressed data, and then merges the compressed data and compression header information into a compressed file and sends it to the email recipient. It should be noted that the file size of the compressed file is not greater than the specified file size.

[0066] The email attachment compression method provided in the present embodiment first obtains the file to be compressed and performs file parsing to obtain a variety of file elements that constitute the file to be compressed. Then, according to the various file elements, the file to be compressed is split into multiple element sets. Finally, the multiple element sets are compressed at the same time to obtain compressed data, and the compressed data and the compression header information are combined into a compressed file and sent to the email recipient. When the embodiment of the present application compresses the split element set, because the element types in each element set are consistent, the element content repetition rate is high, which can improve the compression ratio of each element set and thus improve the compression ratio of large files, so that the file size of the large file after compression can meet the specified size, thereby improving the success rate of sending email attachments.

[0067] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the implementation process of this embodiment, the embodiment of the present application provides a method for compressing email attachments, such as Figure 2 As shown, the method includes:

[0068] 201. Determine the file to be compressed.

[0069] In the embodiment of the present application, considering that most of the attached files in the email to be sent are files that meet the specified size, only a small part are large files that really need to be compressed and sent. Therefore, in the present application, the file compression system configured by the email sender must first determine the files to be compressed in the attached files to be sent. In addition,

[0070] In the actual operation process, the file compression system can read all the attached files of the emails to be sent, determine the occupied space of each attached file of the email to be sent, that is, determine the file size of each attached file. Further, the file compression system compares the occupied space of each attached file of the email to be sent with the preset occupied space threshold one by one, and determines the attached files whose occupied space is greater than the preset occupied space threshold as the files to be compressed. It should be noted that the preset occupied space is used to indicate the maximum attachment size specified by the email sending system. In the actual operation process, the preset occupied space will change with the different email sending systems used. This application does not specifically limit the size of the preset occupied space.

[0071] For example, the preset occupied space is 10GB, the attached file a of the to-be-sent email A occupies 2GB of space, the attached file b of the to-be-sent email B occupies 15KB of space, and the attached file c of the to-be-sent email C occupies 15GB of space. Then, the space occupied by the attached file a, 2GB, is compared with the preset occupied space 10GB. Since 2GB is less than 10GB, the attached file a does not need to be compressed; the space occupied by the attached file b, 15KB, is compared with the preset occupied space 10GB. Since 15KB is less than 10GB, the attached file b does not need to be compressed; the space occupied by the attached file c, 15GB, is compared with the preset occupied space 10GB. Since 2GB is less than 15GB, the attached file c needs to be compressed, and the attached file c is used as the file to be compressed.

[0072] It should be noted that, considering that the sender of an email may carry multiple attached files in an email, at this time, the file compression system reads all the attached files in the email to be sent and determines the space occupied by all the attached files as a whole. That is, if the number of attached files carried by an email is 1, the occupied space of the attached file is directly determined, and the occupied space is compared with the preset occupied space threshold. If the number of attached files carried by an email is greater than 1, the occupied space of multiple attached files as a whole is determined, and the occupied space is compared with the preset occupied space threshold. If the overall occupied space is greater than the preset occupied space threshold, all attached files need to be compressed as files to be compressed. For example, there are three attached files a1, a2 and a3 in the email A to be sent. If the space occupied by a1, a2 and a3 as a whole is greater than the preset occupied space threshold, the three attached files are all treated as files to be compressed.

[0073] 202. Obtain the file to be compressed and perform file parsing to obtain various file elements constituting the file to be compressed, determine the file name of the file to be compressed and the initial occupied space of the file to be compressed, and write the file name and the initial occupied space into the compression information table.

[0074] Among them, the file element is used to indicate all the types of elements that make up the file to be compressed, including numbers, text characters, special symbols, etc. The present application does not specifically limit the specific types of file elements. The method provided in the embodiment of the present application can be applied to a file compression system, and the file compression system determines the attachments to be sent whose occupied space size is greater than a preset occupied space threshold as the files to be compressed among all the attached files to be sent. Then, the file to be compressed is parsed to identify the file elements therefrom, until the file to be compressed is traversed to obtain the multiple file elements that make up the file to be compressed.

[0075] Specifically, after parsing the file to be compressed, the file compression system reads the element content stored in the file to be compressed, and determines the various file elements that make up the file to be compressed. For example, if file a contains only text and numbers throughout, it means that file a is composed of numbers and text, that is, file a includes two types of file elements, namely, digital elements and text elements; if file b contains only numbers, text, and special characters throughout, it means that file b is composed of numbers, text, and special characters, that is, file b includes three types of file elements, namely, digital elements, text elements, and special character elements. At the same time, the file compression system also needs to read the file information of the file to be compressed to determine the file name of the file to be compressed and the initial occupied space of the file to be compressed. Then, the file name and the initial occupied space are written into the compression information table, so that the compression header information can be generated later according to the compression information table.

[0076] 203. Split the file to be compressed into multiple element sets according to multiple file elements.

[0077] In an embodiment of the present application, the file compression system traverses the file to be compressed, determines the element content corresponding to the file element in the file to be compressed, then writes the element content into a specified set and associates the specified set with the file element to obtain an element set of the file element. Finally, an element set is created for each file element to obtain multiple element sets.

[0078] Specifically, the file compression system may first select a file element, and then traverse the entire file to be compressed, extract the element content corresponding to the file element, and write it into the corresponding element set. It should be noted that, for each file element, the file compression system may extract at least one element content corresponding to the file element from the file to be compressed. Furthermore, for multiple file elements, the file compression system extracts the element content for each file element one by one and writes it into the element set, thereby obtaining multiple element sets corresponding to multiple file elements.

[0079] In addition, the file compression system can also decompress the compressed file to restore the compressed file that the email sender wants to send. When the target client wants to send a large file, the file compression system can compress the large file as the file to be compressed, and then send the compressed compressed file to the email recipient. When the target client receives the compressed file, the file compression system decompresses the compressed file to restore the file to be compressed that the email sender wants to send. Specifically, the file compression system needs to determine the location information of the element content in the file to be compressed for the element content corresponding to each file element. The location information is then recorded in the split information table, so that the file compression system corresponding to the subsequent email recipient can decompress the compressed file and restore the file to be compressed according to the location information of each element content recorded in the split information table corresponding to the file to be compressed.

[0080] 204. Perform file compression on multiple element sets at the same time to obtain compressed data, and combine the compressed data with compression header information into a compressed file and send it to an email recipient.

[0081] In the embodiment of the present application, the file compression system compresses different element sets concurrently, and then merges the results obtained after the compression of different element sets to obtain compressed data, and then merges the compressed data and the compression header information into a compressed file and sends it to the email recipient. It should be noted that the file size of the compressed file that can be sent is not greater than the specified preset occupied space threshold.

[0082] Specifically, the file compression system compresses and encodes the element set associated with each file element according to the compression encoding method corresponding to each file element, and obtains the compressed block corresponding to each file element. Further, the split information table is read in the storage space, and the split information table is merged with the compressed block corresponding to each file element to obtain compressed data. After obtaining the compressed data, the file compression system also needs to identify the compressed data, determine the target occupied space after the compressed file is compressed, and write the target occupied space into the compression information table. Further, the file name, initial occupied space and target occupied space recorded in the compression information table are converted into a string type to obtain the compressed header information. Finally, the compressed header information is merged with the compressed data to obtain a compressed file.

[0083] In addition, after obtaining the compressed file, in order to prevent the compressed file from being sent unsuccessfully, it is also necessary to determine the space occupied by the compressed file and compare the space occupied with the preset space occupied. If the comparison result shows that the space occupied is less than or equal to the preset space occupied, the compressed file is directly sent to the email recipient as an email attachment. If the comparison result shows that the space occupied is greater than the preset space occupied, the file to be compressed is recompressed, or other sending methods are used to send the compressed file.

[0084] The method provided in the embodiment of the present application first obtains the file to be compressed and performs file parsing to obtain the various file elements that constitute the file to be compressed. Then, according to the various file elements, the file to be compressed is split into multiple element sets. Finally, the multiple element sets are compressed at the same time to obtain compressed data, and the compressed data is combined with the compression header information into a compressed file and sent to the email recipient. When the embodiment of the present application compresses the split element set, because the element types in each element set are consistent, the element content repetition rate is high, which can improve the compression ratio of each element set and thus improve the compression ratio of large files, so that the file size of the large file after compression can meet the specified size, thereby improving the success rate of sending email attachments.

[0085] Further, as Figure 1In a specific implementation of the method, the present application embodiment provides a device for compressing email attachments, such as Figure 3 As shown, the device includes: an acquisition module 301, a splitting module 302, and a compression module 303.

[0086] The acquisition module 301 is used to acquire the file to be compressed and perform file parsing to obtain multiple file elements constituting the file to be compressed;

[0087] The splitting module 302 is used to split the to-be-compressed file into multiple element sets according to the multiple file elements, wherein each element set records the element content of one file element;

[0088] The compression module 303 is used to simultaneously perform file compression on the multiple element sets to obtain compressed data, and to combine the compressed data with compression header information into a compressed file and send it to the email recipient.

[0089] In specific application scenarios, such as Figure 4 As shown, the device further includes: a reading module 401 and a comparison module 402.

[0090] The reading module 401 is used to read all the attached files of the emails to be sent, and determine the occupied space of each attached file of the email to be sent, so as to obtain the total occupied space corresponding to all the emails to be sent;

[0091] The comparison module 402 is used to compare each occupied space with a preset occupied space threshold one by one, and determine the attached files whose occupied space is greater than the preset occupied space threshold as the files to be compressed.

[0092] In a specific application scenario, the splitting module 302 is used to traverse the file to be compressed for each file element among the multiple file elements, determine the element content corresponding to the file element in the file to be compressed; write the element content into a specified set and associate the specified set with the file element to obtain an element set of the file element; create an element set for each file element to obtain the multiple element sets.

[0093] In a specific application scenario, the splitting module 302 is also used to determine the location information of the element content corresponding to each file element in the file to be compressed; and record the location information in a splitting information table, which is used to record the location information of each element content corresponding to the file to be compressed.

[0094] In a specific application scenario, the compression module 303 is used to compress and encode the element set associated with each file element according to the compression encoding method corresponding to each file element, so as to obtain the compressed block corresponding to each file element; read the split information table, merge the split information table with the compressed block corresponding to each file element, so as to obtain the compressed data.

[0095] In specific application scenarios, such as Figure 5 As shown, the device further includes: a determination module 501 , an identification module 502 , and a conversion module 503 .

[0096] The determination module 501 is used to determine the file name of the to-be-compressed file and the initial occupied space of the to-be-compressed file, and write the file name and the initial occupied space into a compression information table, wherein the compression information table is used to generate the compression header information;

[0097] The identification module 502 is used to identify the compressed data, determine the target occupied space of the compressed file after compression, and write the target occupied space into the compression information table;

[0098] The conversion module 503 is used to convert the file name, initial occupied space and target occupied space recorded in the compression information table into a string type to obtain the compression header information.

[0099] In a specific application scenario, the compression module 303 is used to query the occupied space of the compressed file and a preset occupied space threshold, and compare the occupied space with the preset occupied space threshold; when the comparison result indicates that the occupied space is less than or equal to the preset occupied space, the compressed file is sent as an attached file of the email to the email recipient, so that the email recipient can restore the file to be compressed according to the split information table in the compressed file.

[0100] The device provided in the embodiment of the present application first obtains the file to be compressed and performs file parsing to obtain the various file elements that constitute the file to be compressed. Then, according to the various file elements, the file to be compressed is split into multiple element sets. Finally, the multiple element sets are compressed at the same time to obtain compressed data, and the compressed data is combined with the compression header information into a compressed file and sent to the email recipient. When the embodiment of the present application compresses the split element sets, because the element types in each element set are consistent, the element content repetition rate is high, which can improve the compression ratio of each element set and thus improve the compression ratio of large files, so that the file size of the large file after compression can meet the specified size, thereby improving the success rate of sending email attachments.

[0101] It should be noted that for other corresponding descriptions of the functional units involved in the email attachment compression device provided in the embodiment of the present application, reference can be made to Figure 1 and Figure 2 The corresponding description in will not be repeated here.

[0102] Based on the above Figure 1 , Figure 2 The method shown, accordingly, this embodiment also provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the email attachment compression method are implemented.

[0103] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product. The software product to be identified can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.

[0104] Based on the above Figure 1 , Figure 2 The method shown, and Figure 3 , Figure 4 and Figure 5 In order to achieve the above-mentioned purpose, in the exemplary embodiment, see Figure 6 , and also provides a device, which includes a communication bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the email attachment compression method in the above embodiment.

[0105] Optionally, the physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0106] Those skilled in the art will appreciate that the physical device structure of the email attachment compression method provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.

[0107] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware of the physical device and the software resources to be identified, and supports the operation of the information processing program and other software and / or programs to be identified. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.

[0108] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the technical solution of the present application, the file to be compressed is first obtained for file parsing to obtain a variety of file elements that constitute the file to be compressed. Then, according to the various file elements, the file to be compressed is split into multiple element sets. Finally, file compression is performed on multiple element sets at the same time to obtain compressed data, and the compressed data and the compression header information are combined into a compressed file and sent to the email recipient. Compared with the prior art, when the embodiment of the present application compresses the split element set, because the element types in each element set are consistent, there is no need to switch different compression encoding methods, and compression can be performed only according to the compression encoding method corresponding to the element set, thereby improving the file compression performance and shortening the file compression time.

[0109] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required for implementing the present application.

[0110] Those skilled in the art will appreciate that the modules in the device in the implementation scenario can be distributed in the device in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple sub-modules.

[0111] The above application serial numbers are for description only and do not represent the advantages or disadvantages of the implementation scenarios.

[0112] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.

Claims

1. A method for compressing mail attachments, characterized in that: include: Obtaining a file to be compressed and performing file parsing to obtain multiple file elements constituting the file to be compressed; According to the multiple file elements, split the to-be-compressed file into multiple element sets, wherein each element set records the element content of one file element; At the same time, the plurality of element sets are compressed to obtain compressed data, and the compressed data is combined with the compression header information into a compressed file and sent to the email recipient.

2. The method according to claim 1, characterized in that Before obtaining the file to be compressed and performing file parsing, the method further includes: Reading all the attached files of the mails to be sent, and determining the occupied space of each of the attached files of the mails to be sent, to obtain the total occupied space corresponding to all the mails to be sent; Each occupied space is compared with a preset occupied space threshold one by one, and the attached files whose occupied space is greater than the preset occupied space threshold are determined as the files to be compressed.

3. The method according to claim 1, characterized in that: The step of splitting the to-be-compressed file into a plurality of element sets according to the plurality of file elements comprises: For each file element among the multiple file elements, traverse the to-be-compressed file, and determine the element content corresponding to the file element in the to-be-compressed file; Writing the element content into a specified set and associating the specified set with the file element to obtain an element set of the file element; An element set is created for each file element to obtain the multiple element sets.

4. The method according to claim 3, characterized in that After writing the element content into a specified set and associating the specified set with the file element to obtain the element set of the file element, the method further includes: For element content corresponding to each file element, determining location information of the element content in the file to be compressed; The position information is recorded in a split information table, where the split information table is used to record the position information of each element content corresponding to the file to be compressed.

5. The method according to claim 1, characterized in that The simultaneously performing file compression on the multiple element sets to obtain compressed data includes: According to the compression encoding mode corresponding to each file element, the element set associated with each file element is compressed and encoded to obtain a compressed block corresponding to each file element; The split information table is read, and the split information table is merged with the compressed blocks corresponding to each of the file elements to obtain the compressed data.

6. The method according to claim 1, characterized in that Before combining the compressed data and the compressed header information into a compressed file and sending it to the email recipient, the method further includes: Determine the file name of the to-be-compressed file and the initial occupied space of the to-be-compressed file, write the file name and the initial occupied space into a compression information table, and the compression information table is used to generate the compression header information; Identifying the compressed data, determining the target occupied space of the to-be-compressed file after compression, and writing the target occupied space into the compression information table; The file name, the initial occupied space and the target occupied space recorded in the compression information table are converted into a string type to obtain the compression header information.

7. The method according to claim 1, characterized in that The step of sending the compressed file to an email recipient includes: querying the occupied space of the compressed file and a preset occupied space threshold, and comparing the occupied space with the preset occupied space threshold; When the comparison result indicates that the occupied space is less than or equal to the preset occupied space, the compressed file is sent to the email recipient as an attached file of the email, so that the email recipient can restore the file to be compressed according to the split information table in the compressed file.

8. A mail attachment compression device, characterized in that: include: An acquisition module, used for acquiring a file to be compressed, performing file parsing, and obtaining a plurality of file elements constituting the file to be compressed; A splitting module, used for splitting the to-be-compressed file into a plurality of element sets according to the plurality of file elements, wherein each element set records the element content of a file element; The compression module is used to simultaneously perform file compression on the multiple element sets to obtain compressed data, and to combine the compressed data with compression header information into a compressed file and send it to the email recipient.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • File format conversion method and device, computer device and storage medium

    CN109002424A

  • Mail sending method and device and mail receiving method and device

    CN112134789A

  • File compression processing method and device, equipment and medium

    CN116303297A

  • Mail indexing and searching using hierarchical caches

    US20140089258A1

  • Method and apparatus for compressing attachments to electronic mail communications for transmission

    US7089286B1