Image segmentation transmission method, system, terminal and server under extreme network environment
Technical Field
The invention relates to the technical field of picture transmission, in particular to a picture segmentation transmission method, a system, a terminal and a server under an extreme network environment.
Background
With the continuous development of information technology and the continuous enhancement of social demand, the development of information industry is changing day by day, and there are higher requirements on the quality, high speed and accuracy of communication transmission, the explosion development of mobile application enables people to work and upload field pictures at any time and any place through mobile software, which all need wireless network to perform communication transmission, more working scenes need to be completed by uploading pictures, and when the communication signal is poor, unexpected interruption occurs, the network security policy does not allow the use of file stream mode transmission, and the data request length is limited, the uploading of files such as pictures and the like is limited, or the picture with larger volume cannot be successfully uploaded.
Disclosure of Invention
The invention provides a picture segmentation transmission method in an extreme network environment, overcomes the defects of the prior art, and can effectively solve the problems that the picture is difficult to upload and is difficult to succeed when the network is poor or the data request length is limited in the prior art.
One of the technical schemes of the invention is realized by the following measures: a picture segmentation transmission method under an extreme network environment comprises the following steps:
converting the picture code into a long character string and generating a unique picture identifier corresponding to the picture;
presetting segmentation character string splitting length, sequentially splitting a long character string into a plurality of segments of segmentation character strings according to the splitting length, and generating splitting sequence identification according to the splitting sequence of the segmentation character strings;
establishing a network request, and uploading a picture identifier, a splitting sequence identifier and all the segmented character strings to a server according to the splitting sequence of the segmented character strings;
the server judges whether all the segmented character strings are acquired or not, and if so, all the segmented character strings are spliced according to the splitting sequence identification to restore the long character string;
and decoding and converting the long character string into the original picture.
The following is further optimization or/and improvement of the technical scheme of the invention:
the server determines whether to acquire all the segmented character strings, and specifically includes:
after receiving each network request, the server judges whether the splitting sequence identification is consistent with the number of the received segmented character strings;
and in response to the coincidence, the server judges that the current network request is the last request, namely all the segmented character strings are acquired, and in response to the coincidence, the segmented character strings are stored.
When the network request is established and the picture identifier, the splitting order identifier and all the segmented character strings are uploaded to the server according to the splitting order of the segmented character strings, the network request specifically comprises the following steps:
establishing a cyclic network request, wherein the number of the cyclic times is the same as the number of the segmented character strings;
according to the splitting sequence of the segmented character strings, uploading picture identification, splitting sequence identification and corresponding segmented character strings to a server in each network request;
and if the uploading fails, the current data is uploaded again, and if the uploading succeeds, the new data is continuously uploaded.
The pictures are converted into long character strings through the Base64 coding mode.
The long character string is converted into the original picture by the Base64 coding mode
The second technical scheme of the invention is realized by the following measures: a picture segmentation transmission system under an extreme network environment comprises a server and a terminal;
the terminal is used for converting the picture code into a long character string and generating a unique picture identifier corresponding to the picture; splitting the long character string to generate a splitting sequence identifier; uploading all the segmented character strings, the picture identifications and the splitting sequence identifications to a server;
and the server is used for judging whether all the segmented character strings are acquired or not, splicing all the segmented character strings according to the splitting sequence identifier in response to the acquisition, restoring the long character string, and decoding and converting the long character string into the original picture.
The third technical scheme of the invention is realized by the following measures: a terminal comprises a picture conversion unit, a long character string splitting unit and a segmented character string uploading unit;
the picture conversion unit is used for converting picture codes into long character strings and generating a unique picture identifier corresponding to the picture;
the long character string splitting unit is used for presetting a splitting length of the segmented character string, sequentially splitting the long character string into a plurality of segments of segmented character strings according to the splitting length, and generating splitting sequence identifiers according to the splitting sequence of the segmented character strings;
and the segmented character string uploading unit is used for establishing a network request and uploading the picture identifier, the splitting sequence identifier and all the segmented character strings to the server according to the splitting sequence of the segmented character strings.
The fourth technical scheme of the invention is realized by the following measures: a server comprises a receiving unit, a splicing unit and a restoring unit;
the receiving unit is used for receiving the picture identification, the splitting sequence identification and the segmentation character strings and judging whether all the segmentation character strings are acquired or not;
the splicing unit is used for splicing all the segmented character strings according to the splitting sequence identification after the segmented character strings are received, and restoring the long character strings;
and the restoring unit is used for decoding and converting the long character string into an original picture.
According to the invention, the picture file is transcoded and then split, and then the network requests to send the request and the request is restored in the server, so that the success rate and the transmission stability of picture uploading can be effectively ensured under an extreme network environment, and better network experience is brought to users.
Drawings
FIG. 1 is a flow chart of example 1 of the present invention.
Fig. 2 is a flowchart of acquiring all segmented character strings by a server in embodiment 1 of the present invention.
Fig. 3 is a flowchart of transmitting a picture identifier, a split order identifier, and all segmented character strings in embodiment 1 of the present invention.
Fig. 4 is a block diagram of the system configuration of embodiment 2 of the present invention.
Fig. 5 is a block diagram of a terminal structure according to embodiment 3 of the present invention.
Fig. 6 is a block diagram of a server according to embodiment 4 of the present invention.
Detailed Description
The present invention is not limited by the following examples, and specific embodiments may be determined according to the technical solutions and practical situations of the present invention.
The invention is further described with reference to the following examples and figures:
example 1: as shown in fig. 1, the method for transmitting the picture segmentation under the extreme network environment includes the following steps:
s1, converting the picture code into a long character string and generating a unique picture identifier corresponding to the picture;
s2, presetting segmentation character string splitting length, sequentially splitting a long character string into a plurality of segments of segmentation character strings according to the splitting length, and generating splitting sequence identification according to the splitting sequence of the segmentation character strings;
s3, establishing a network request, and uploading the picture identifier, the splitting sequence identifier and all the segmented character strings to a server according to the splitting sequence of the segmented character strings;
s4, the server judges whether to obtain all the segmented character strings, and if so, the server splices all the segmented character strings according to the split sequence identifier to restore the long character string;
and S5, decoding and converting the long character string into an original picture.
In the above S1, the HTML of the picture is first converted into the IMG object, then the Base64 encoding method of JavaScript is used to convert the binary IMG object of the picture into the long character string str OfBase64 foreimg, and a picture identifier IdOfIMG is generated. In S2, the length of the long string strOfBase64 foremg is calculated first, and then the string is split according to the preset splitting length L of the segmented string, the total number of the split long strings is defined as countofstrforemg, and each segmented string is defined as a splitting sequence identifier str (n) according to the splitting sequence.
According to the invention, the picture file is transcoded and then split, and then the network requests to send the request and the request is restored in the server, so that the success rate and the transmission stability of picture uploading can be effectively ensured under an extreme network environment, and better network experience is brought to users.
The following is further optimization or/and improvement of the technical scheme of the invention:
as shown in fig. 1 and 2, when the server determines whether to acquire all the segmented character strings, the method specifically includes:
s41, after the server receives a network request, the server judges whether the splitting sequence identification STR (n) is consistent with the received number countOfStrForIMG of the segmented character strings;
and S41, in response to the coincidence, the server judges that the current network request is the last request, namely all the segmented character strings are acquired, and in response to the coincidence, the segmented character strings are stored.
As shown in fig. 1 and 3, when the network request is established, and the picture identifier, the split sequence identifier, and all the segmented character strings are uploaded to the server according to the split sequence of the segmented character strings, the network request specifically includes:
s31, establishing a cyclic network request, wherein the cycle number is the same as the number countOfStrForIMG of the segmented character strings;
s32, according to the splitting sequence of the segmented character strings, uploading the picture identification, the splitting sequence identification STR (n) and the corresponding segmented character strings to the server in each network request;
and S33, if the uploading fails, the current data is uploaded again, and if the uploading is successful, the new data is continuously uploaded.
As shown in FIG. 1, the pictures are converted into long character strings through a Base64 coding mode.
As shown in fig. 1, the long character string is converted into the original picture through a Base64 coding mode.
Example 2: as shown in fig. 1 and 4, the picture splitting transmission system in the extreme network environment includes a server and a terminal;
the terminal is used for converting the picture code into a long character string and generating a unique picture identifier corresponding to the picture; splitting the long character string to generate a splitting sequence identifier; uploading all the segmented character strings, the picture identifications and the splitting sequence identifications to a server;
and the server is used for judging whether all the segmented character strings are acquired or not, splicing all the segmented character strings according to the splitting sequence identifier in response to the acquisition, restoring the long character string, and decoding and converting the long character string into the original picture.
Example 3: as shown in fig. 1 and 5, the terminal includes a picture conversion unit, a long character string splitting unit, and a segmented character string uploading unit;
the picture conversion unit is used for converting picture codes into long character strings and generating a unique picture identifier corresponding to the picture;
the long character string splitting unit is used for presetting a splitting length of the segmented character string, sequentially splitting the long character string into a plurality of segments of segmented character strings according to the splitting length, and generating splitting sequence identifiers according to the splitting sequence of the segmented character strings;
and the segmented character string uploading unit is used for establishing a network request and uploading the picture identifier, the splitting sequence identifier and all the segmented character strings to the server according to the splitting sequence of the segmented character strings.
Example 4: as shown in fig. 1 and 6, the server includes a receiving unit, a splicing unit and a restoring unit;
the receiving unit is used for receiving the picture identification, the splitting sequence identification and the segmentation character strings and judging whether all the segmentation character strings are acquired or not;
the splicing unit is used for splicing all the segmented character strings according to the splitting sequence identification after the segmented character strings are received, and restoring the long character strings;
and the restoring unit is used for decoding and converting the long character string into an original picture.
The above technical features constitute the best embodiment of the present invention, which has strong adaptability and best implementation effect, and unnecessary technical features can be increased or decreased according to actual needs to meet the requirements of different situations.