Method for remotely updating resource file
Through the combination of subcontracted download, multiple hash checks and dynamic server configuration, the problems of high network occupation, insufficient verification and low security in remote resource file updates are solved, and efficient and secure resource file updates are achieved.
Patent Information
- Application Number
- CN202510482281.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-08
AI Technical Summary
The existing technology remote resource file update method has problems such as high network bandwidth usage when downloading large files, easy interruption, lack of effective verification mechanism, difficulty in adapting to changing business needs, and low security.
It adopts the combination of subcontracted download, multiple hash verification, server-side dynamic configuration and HTTPS encrypted transmission to achieve efficient and secure resource file updates.
It improves the efficiency and reliability of resource updates, reduces network bandwidth consumption and storage costs, and enhances system flexibility and security.
Smart Images

Figure CN120281648A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a method for remotely updating resource files. Background Art
[0002] With the rapid development of information technology, remote resource file updating has wide applications in fields such as Internet of Things devices, mobile terminals, and embedded systems. Traditional resource file updating methods usually adopt the whole-package download mode, where the terminal directly downloads the complete file from the server and then replaces the local file.
[0003] However, such methods have the following significant problems in practical applications: (1) The prior art does not perform sub-packet processing on files, resulting in high network bandwidth occupancy during the download of large files and prone to transmission interruption due to network fluctuations, and the need to re-download the entire file, with low efficiency. (2) Traditional methods lack an effective verification mechanism and only rely on simple file size comparison, unable to detect file corruption or tampering that may occur during transmission, posing a security risk. (3) The server cannot dynamically configure the type, path, and version information of resource files, and the terminal needs to rely on fixed rules to execute the update, making it difficult to adapt to changing business requirements. For example, it is impossible to achieve incremental updates of files or delete redundant files on demand. (4) The prior art usually only supports overwrite updates of files and cannot intelligently manage local files (such as adding, updating, or deleting) according to the task list sent by the server, resulting in waste of terminal storage space and increased maintenance costs.
[0004] To address the above problems, some existing solutions have attempted to introduce breakpoint resumption or hash verification, but there are still limitations. For example, although some methods support sub-packet downloads, they do not combine with the download task list dynamically configured by the server, resulting in a rigid update process; other solutions use hash verification, but only for individual files and do not perform multiple verifications at the sub-packet level and the overall file level, with insufficient reliability. In addition, the interaction protocol between the terminal and the server in the prior art has low security and is vulnerable to man-in-the-middle attacks, leading to leakage of sensitive data. Summary of the Invention
[0005] The present invention provides a method for remotely updating resource files that can support efficient sub-packet transmission, multiple verification mechanisms, dynamic configuration management, and high security, to solve the deficiencies in the prior art and improve the efficiency, reliability, and flexibility of resource updates.
[0006] The technical solution adopted by the present invention is as follows: A method for remotely updating resource files, comprising the following steps:
[0007] Step 1: The terminal establishes a connection with the TMS server and sends identity information, version information, and authentication information to the TMS server;
[0008] Step 2: After the TMS server verifies the identity of the terminal, it queries and sends the download task information to the terminal. The download task information includes the total number, type, storage path, and hash check value of the resource files.
[0009] Step 3: The terminal creates a temporary download list according to the download task information and initiates a sub-packet download request for the resource files in sequence. Among them, the sub-packet download request includes the current packet number and the requested data size, and the TMS server returns the corresponding packet data and the total number of packets.
[0010] Step 4: The terminal downloads all sub-packet data in a loop. After each packet is downloaded, it is stored in the area to be updated, and the integrity and legality of the whole packet are verified after all packets are downloaded.
[0011] Step 5: The terminal performs an update operation on the local files according to the temporary download list, including: if the file does not exist locally, the file is newly added; if the file exists and the hash value is inconsistent with the downloaded file, the file is updated; if the file exists and the hash value is consistent, the operation is skipped.
[0012] Step 6: The terminal traverses the local file list and deletes the files not included in the temporary download list.
[0013] Step 7: Update the local file list to complete the remote update of the resource files.
[0014] As a further improvement of the present invention, in the step 3, the specific method of sub-packet download is: the terminal and the server agree on the single-packet download size, and the server calculates the total number of packets according to the total file size; the terminal requests the next packet of data in sequence according to the current download progress until the last packet is downloaded.
[0015] As a further improvement of the present invention, in the step 5, at least one of the MD5, SHA-1, and SHA-256 algorithms is used for hash value verification.
[0016] As a further improvement of the present invention, the download task information is dynamically configured by the server, and supports real-time updating of the type, path, and version information of the resource files.
[0017] As a further improvement of the present invention, the creation method of the temporary download list includes: generating a priority order according to the resource file information sent by the server; supporting resume from breakpoint after interruption, and resuming the download task based on the downloaded packet number.
[0018] As a further improvement of the present invention, in the step 4, verifying the integrity and legality includes: comparing the hash value of the whole packet with the hash value provided by the server; verifying whether the file format conforms to the predefined type.
[0019] As a further improvement of the present invention, the connection between the terminal and the TMS server uses the HTTPS protocol for encrypted transmission to ensure data security.
[0020] As a further improvement of the present invention, the resource files include, but are not limited to, configuration files, media files, application patches, or firmware upgrade packages.
[0021] As a further improvement of the present invention, the terminal is one of an Internet of Things device, a mobile terminal, or an embedded device.
[0022] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0023] The beneficial effects of the present invention: Through the combined action of the sub-packet download mechanism, multiple hash checks, and server-side dynamic configuration, the present invention realizes the efficient incremental update and intelligent management of resource files on the premise of ensuring the security and integrity of file transmission. Specifically, it supports segmented resume of large files to reduce the impact of network fluctuations, prevents data tampering through double verification at the sub-packet level and the whole-packet level, combines a dynamic task list to automatically complete file addition, update, and redundant deletion, and finally significantly improves the update efficiency in resource-constrained scenarios such as Internet of Things devices, reduces bandwidth consumption and storage costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a schematic diagram of the interaction between the terminal and the TMS server of a method for remotely updating resource files according to the present invention;
[0025] Figure 2 is the overall flow block diagram of a method for remotely updating resource files according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] In order to make the technical problems, technical solutions, and beneficial effects to be solved by the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] The present invention provides a method for remotely updating resource files, including the following steps:
[0028] Step 1: The terminal establishes a connection with the TMS server and sends identity information, version information, and authentication information to the TMS server;
[0029] Step 2: After verifying the identity of the terminal, the TMS server queries and sends download task information to the terminal. The download task information includes the total number, type, storage path, and hash check value of the resource files;
[0030] Step 3: The terminal creates a temporary download list based on the download task information and initiates a sub-packet download request for the resource file in sequence; among them, the sub-packet download request includes the current packet number and the requested data size, and the TMS server returns the corresponding packet data and the total number of packets;
[0031] Step 4: The terminal downloads all sub-packet data in a loop. After each packet is downloaded, it is stored in the area to be updated, and the integrity and legality of the whole packet are verified after all packets are downloaded;
[0032] Step 5: The terminal performs an update operation on the local file according to the temporary download list, including: if the file does not exist locally, a new file is added; if the file exists and the hash value is inconsistent with the downloaded file, the file is updated; if the file exists and the hash value is consistent, the operation is skipped;
[0033] Step 6: The terminal traverses the local file list and deletes the files not included in the temporary download list;
[0034] Step 7: Update the local file list to complete the remote update of the resource file.
[0035] In step 3 of the present invention, the specific method of sub-packet download is: the terminal and the server agree on the single-packet download size, and the server calculates the total number of packets according to the total file size; the terminal requests the next packet of data in sequence according to the current download progress until the last packet is downloaded.
[0036] In step 5 of the present invention, the hash value verification adopts at least one of the MD5, SHA-1, and SHA-256 algorithms.
[0037] In the present invention, the download task information is dynamically configured by the server, and supports real-time updating of the type, path, and version information of the resource file.
[0038] The creation method of the temporary download list in the present invention includes: generating a priority order according to the resource file information sent by the server; supporting resume from breakpoint after interruption, and resuming the download task based on the downloaded packet number.
[0039] In step 4 of the present invention, verifying the integrity and legality includes: comparing the hash value of the whole packet with the hash value provided by the server; verifying whether the file format conforms to the predefined type.
[0040] In the present invention, the connection between the terminal and the TMS server uses the HTTPS protocol for encrypted transmission to ensure data security.
[0041] In the present invention, the resource file includes but is not limited to configuration files, media files, application patches, or firmware upgrade packages.
[0042] In the present invention, the terminal is one of an Internet of Things device, a mobile terminal, and an embedded device.
[0043] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0044] Example:
[0045] This embodiment takes the firmware upgrade of an IoT device (such as a smart meter) as an example to illustrate the specific implementation process of the method for remotely updating resource files.
[0046] Step 1: Establish a secure connection between the terminal and the TMS server
[0047] The terminal (smart meter model XYZ-2000) establishes an encrypted communication connection with the TMS server through the HTTPS protocol. The terminal sends identity information (including the device unique ID DEV_001), the current firmware version number (v2.1.3) and the authentication token (a dynamic token generated by a preset key) to the server.
[0048] Step 2: The server verifies the identity and sends the download task
[0049] After receiving the request from the terminal, the TMS server first verifies the legitimacy of the device ID and authentication token. After the verification is passed, the server queries whether the terminal needs to perform a firmware upgrade task.
[0050] If an upgrade is required, the server sends dynamically configured download task information, including: (1) resource file type: firmware upgrade package (.bin file); (2) total number of files: 1; (3) storage path: / firmware / update / ; (4) file hash value (SHA-256): a1b2c3d4e5...; (5) total file size: 50MB; (6) single package download size: 1MB (50 packages in total).
[0051] Step 3: The terminal creates a temporary download list and starts the sub-package download
[0052] The terminal generates a temporary download list based on the task information sent by the server and sets the firmware upgrade package as the highest priority task.
[0053] Subsequently, the terminal initiates a packet download request to the server: (1) First request: Send packet number 1 and request data size 1MB; (2) Server response: Return the data block of packet number 1 and the total number of packets 50; (3) Loop request: The terminal requests packet numbers 2 to 50 in sequence until all downloads are completed.
[0054] If the network is interrupted during the download process (such as the download of the 25th package fails), the terminal records the downloaded package numbers (1-24) and continues to request from package number 25 after the network is restored, thus achieving breakpoint resume.
[0055] Step 4: Verify the integrity and legality of the entire package
[0056] After all sub-packages are downloaded, the terminal concatenates the 50 data packets in sequence into a complete firmware file and performs a double verification: (1) Whole-package hash verification: Calculate the SHA-256 hash value of the local file and compare it with a1b2c3d4e5... provided by the server to ensure that the file has not been tampered with; (2) Format legality verification: Check that the file extension is.bin, which conforms to the predefined type of the firmware upgrade package.
[0057] Step 5: Perform local file update
[0058] After the verification passes, the terminal updates the local files according to the temporary download list: (1) New addition operation: If there is no file with the same name in the / firmware / update / path, store the downloaded firmware package in this path; (2) Update operation: If there is an old version of the firmware (such as v2.1.3) and the hash values are inconsistent, overwrite the old file; (3) Skip operation: If the hash value of the local file is the same as that of the downloaded file, there is no need to update.
[0059] Step 6: Clean up redundant files
[0060] The terminal traverses the list of firmware files stored locally and deletes redundant files (such as the firmware package of the historical version v2.1.2) that are not included in the temporary download list to free up storage space.
[0061] Step 7: Update the local file list and complete the upgrade
[0062] The terminal writes the new firmware information (version number v2.1.4, storage path, hash value) into the local configuration file, and after restarting, loads the new firmware to complete the remote upgrade process.
[0063] Effect verification
[0064] In this embodiment, the time taken for the 50MB firmware to be downloaded in sub-packages (1MB per package) is shortened by 30% compared to traditional whole-package downloads, and after a network interruption, only the remaining packages (instead of the entire file) need to be retransmitted, reducing the bandwidth consumption by 60%. Through the SHA-256 double verification, the file transfer error rate is reduced to less than 0.01%. In addition, the dynamic task list enables the server to push upgrade packages for different device types in real time (such as supporting electricity meters and water meters simultaneously), significantly improving management flexibility.
[0065] As can be seen from the above embodiments, a method for remotely updating resource files according to the present invention not only significantly improves the efficiency and reliability of resource updates, but also greatly enhances the flexibility and security of the system. By introducing a subpackage download mechanism, the present invention effectively reduces the occupancy of network bandwidth by large file transmissions, and at the same time supports the breakpoint resume function. Even in the case of transmission interruption caused by network fluctuations, it can continue downloading from the breakpoint without having to redownload the entire file, thus significantly improving the download efficiency. In addition, combined with a multiple hash verification mechanism, the present invention performs strict verification at both the subpackage level and the overall file level, ensuring the integrity and legality of the file during transmission, effectively preventing data tampering and damage, and further enhancing the system security.
[0066] In terms of dynamic configuration management on the server side, the present invention allows the server to update the type, path, and version information of resource files in real time according to actual needs, and the terminal automatically completes operations such as adding, updating, and redundant deletion of files according to the dynamic task list issued by the server, without relying on fixed rules to execute updates, thus being able to better adapt to changing business requirements. This feature not only improves the flexibility of the system, but also effectively avoids waste of terminal storage space and reduces maintenance costs.
[0067] In summary, through a series of innovative technical means, the present invention has successfully solved many defects existing in the existing methods for remotely updating resource files, providing an efficient, reliable, and flexible solution for resource updates in resource-constrained scenarios such as Internet of Things devices, mobile terminals, and embedded devices.
[0068] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for remotely updating a resource file, characterized in that, It includes the following steps: Step 1: The terminal establishes a connection with the TMS server and sends identity information, version information, and authentication information to the TMS server; Step 2: After verifying the identity of the terminal, the TMS server queries and sends download task information to the terminal. The download task information includes the total number of resource files, types, storage paths, and hash verification values; Step 3: The terminal creates a temporary download list according to the download task information and initiates a sub-packet download request for the resource files in sequence. Among them, the sub-packet download request includes the current packet sequence number and the requested data size, and the TMS server returns the corresponding packet data and the total number of packets; Step 4: The terminal downloads all sub-packet data in a loop. After each packet is downloaded, it is stored in the area to be updated, and the integrity and legality of the entire packet are verified after all packets are downloaded; Step 5: The terminal performs an update operation on the local files according to the temporary download list, including: if the file does not exist locally, the file is newly added; if the file exists and the hash value is inconsistent with the downloaded file, the file is updated; if the file exists and the hash value is consistent, the operation is skipped; Step 6: The terminal traverses the local file list and deletes the files not included in the temporary download list; Step 7: Update the local file list to complete the remote update of the resource files.
2. The method for remotely updating a resource file according to claim 1, wherein In Step 3, the specific method of sub-packet download is: The terminal and the server agree on the single-packet download size, and the server calculates the total number of packets according to the total file size; The terminal requests the next packet of data in sequence according to the current download progress until the last packet is downloaded.
3. A method for remotely updating a resource file according to claim 1, wherein, In Step 5, at least one of the MD5, SHA-1, and SHA-256 algorithms is used for hash value verification.
4. A method for remotely updating a resource file according to claim 1, characterized in that, The download task information is dynamically configured by the server and supports real-time update of the type, path, and version information of the resource files.
5. A method for remotely updating a resource file according to claim 1, characterized in that, The creation method of the temporary download list includes: generating a priority order according to the resource file information sent by the server; supporting resume from breakpoint after interruption and resuming the download task based on the downloaded packet sequence number.
6. A method for remotely updating a resource file according to claim 1, characterized in that, In Step 4, verifying integrity and legality includes: comparing the hash value of the entire packet with the hash value provided by the server; verifying whether the file format conforms to the predefined type.
7. A method for remotely updating a resource file according to claim 1, characterized in that, The connection between the terminal and the TMS server uses HTTPS protocol for encrypted transmission to ensure data security.
8. A method for remotely updating a resource file according to claim 1, characterized in that, The resource files include, but are not limited to, configuration files, media files, application program patches, or firmware upgrade packages.
9. A method for remotely updating a resource file according to claim 1, characterized in that, The terminal is one of an Internet of Things device, a mobile terminal, and an embedded device.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-9.
Citation Information
Cited By
Charging pile firmware online upgrading method and system
CN121567571A