[go: up one dir, main page]

WO2018010469A1 - 一种数据传输方法及装置、存储介质 - Google Patents

一种数据传输方法及装置、存储介质 Download PDF

Info

Publication number
WO2018010469A1
WO2018010469A1 PCT/CN2017/081964 CN2017081964W WO2018010469A1 WO 2018010469 A1 WO2018010469 A1 WO 2018010469A1 CN 2017081964 W CN2017081964 W CN 2017081964W WO 2018010469 A1 WO2018010469 A1 WO 2018010469A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
terminal
data
preview
request
Prior art date
Application number
PCT/CN2017/081964
Other languages
English (en)
French (fr)
Inventor
晁鹏辉
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2018010469A1 publication Critical patent/WO2018010469A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications

Definitions

  • the present invention relates to the field of communications, and in particular, to a data transmission method and apparatus, and a storage medium.
  • Some terminal devices have the function of sharing files in a LAN environment or directly sharing files through Wireless-Fidelity (Wi-Fi), so that users can share files conveniently without cost data. flow.
  • Wi-Fi Wireless-Fidelity
  • the basic process of sharing files through a LAN or Wi-Fi in a terminal device is as follows: 1) Make two terminal devices with the same application in the same LAN, or two terminal devices with the same application through Wi-Fi. Directly connected; 2) The user selects one or more files to be sent in the file stored locally by the terminal device as the sender, and clicks the send button; 3) the terminal device as the receiver passively receives the file of the sender.
  • the terminal device as the receiver can only passively receive the file, and the user experience is not good.
  • an embodiment of the present invention is to provide a data transmission method and apparatus, and a storage medium, so that a file receiver can actively acquire a file, thereby improving user experience.
  • the first aspect provides a data transmission method, the method comprising:
  • the first terminal sends a file preview request to the second terminal, where the file preview request is used to request previewing at least one file data stored by the second terminal;
  • the first terminal receives at least one file preview data sent by the second terminal according to the file preview request, and the file preview data can represent file data, and the size of each file preview data is smaller than the size of the corresponding file data. ;
  • the first terminal receives the at least one file data indicated by the file transmission indication sent by the second terminal according to the file transmission request.
  • the method before the sending, by the first terminal, the file preview request to the second terminal, the method further includes:
  • UDP User Datagram Protocol
  • the first terminal establishes a first Transmission Control Protocol (TCP) connection and a second TCP connection, where the first TCP connection and the second TCP connection have different port numbers;
  • TCP Transmission Control Protocol
  • the first terminal sends a file preview request to the second terminal, including:
  • the first terminal receives the at least one file preview data that is sent by the second terminal according to the file preview request, and includes:
  • the first terminal sends a file transmission request generated by the file transmission indication to the second terminal, including:
  • the receiving, by the first terminal, the at least one file data indicated by the file transmission indication sent by the second terminal, according to the file transmission request includes:
  • the file preview data includes at least a thumbnail of the previewed file data
  • the file preview request includes a file type and a thumbnail size of file data requesting preview
  • the first terminal receives the at least one file preview data that is sent by the second terminal according to the file preview request, and includes:
  • the first terminal receives a file name, a file type, a file size, and thumbnail encoded data of at least one previewed file data that is sent by the second terminal based on the file preview request.
  • the method further includes:
  • the first terminal displays the at least one file preview data to a user
  • the first terminal acquires a file transmission indication, including:
  • the first terminal acquires file preview data selected by the user from the at least one file preview data, and generates the file transmission indication according to at least one file preview data selected by the user.
  • the file transfer indication is used to indicate file data corresponding to at least one file preview data selected by the transfer user.
  • a second aspect provides a data transmission method, the method comprising:
  • the second terminal sends at least one file preview data to the first terminal based on the file preview request, where the file preview data can represent file data, and the size of each file preview data is smaller than the size of the corresponding file data;
  • the second terminal receives the first terminal to send a file transmission request; the file transmission request is generated by the first terminal based on a file transmission indication; and the file transmission indication is used to indicate that the transmission is selected from the at least one At least one file data represented by the file preview data;
  • the method before the second terminal receives the file preview request sent by the first terminal, the method further includes:
  • the second terminal establishes a first TCP connection and a second TCP connection with the first terminal, where the port numbers of the first TCP connection and the second TCP connection are different;
  • the second terminal receives the file preview request sent by the first terminal, including:
  • the second terminal sends the at least one file preview data to the first terminal according to the file preview request, including:
  • the second terminal sends at least one file preview data to the first terminal by using the file preview request and by using the first TCP connection;
  • the receiving, by the second terminal, the file transmission request by the first terminal includes:
  • the sending, by the second terminal, the at least one file data indicated by the file transmission indication to the first terminal, according to the file transmission request includes:
  • the second terminal sends the at least one file data indicated by the file transmission indication to the first terminal by using the second TCP connection based on the file transmission request.
  • the method before the second terminal sends the at least one file preview data to the first terminal, the method further includes:
  • the second terminal generates at least one file preview data characterizing at least one file data according to the file preview request.
  • the file preview data includes at least a thumbnail of the previewed file data
  • the file preview request includes a file type and a thumbnail size of file data requesting preview
  • the second terminal sends the at least one file preview data to the first terminal according to the file preview request, including:
  • the second terminal transmits a file name, a file type, a file size, and thumbnail encoded data of the at least one previewed file data to the first terminal based on the file preview request.
  • a third aspect provides a data transmission apparatus, the apparatus comprising:
  • a first sending module configured to send a file preview request to the second terminal, where the file preview request is used to request previewing at least one file data stored by the second terminal;
  • the first receiving module is configured to receive at least one file preview data that is sent by the second terminal according to the file preview request, where the file preview data can represent file data, and the size of each file preview data is smaller than the corresponding file data. the size of;
  • Obtaining a module configured to obtain a file transfer indication input by the user, where the file transfer indication is used to indicate that the at least one file data selected from the at least one file preview data is transmitted;
  • the first sending module is further configured to send, to the second terminal, a file transfer request generated based on the file transfer indication;
  • the first receiving module is further configured to receive the at least one file data indicated by the file transmission indication sent by the second terminal according to the file transmission request.
  • the first receiving module is further configured to receive a UDP broadcast message sent by the second terminal;
  • the device further includes: a first connection establishing module, configured to establish a first TCP connection and a second TCP connection with the second terminal, where the port numbers of the first TCP connection and the second TCP connection are different;
  • the first sending module is further configured to send the file preview request to the second terminal by using the first TCP connection, and send the second terminal according to the first TCP connection.
  • the file transfer request generated by the file transfer indication;
  • the first receiving module is further configured to receive, by using the first TCP connection, at least one file preview data that is sent by the second terminal based on the file preview request; and receive the second by using the second TCP connection The at least one file data indicated by the file transmission indication sent by the terminal based on the file transfer request.
  • the file preview data includes at least a thumbnail of the previewed file data
  • the file preview request includes a file type and a thumbnail size of file data requesting preview
  • the first receiving module is further configured to receive a file name, a file type, and a file of the file data of the at least one preview that is sent by the second terminal based on the file preview request.
  • Piece size and thumbnail encoded data are further configured to receive a file name, a file type, and a file of the file data of the at least one preview that is sent by the second terminal based on the file preview request.
  • the device further includes: a display module, configured to display the at least one file preview data to a user;
  • the acquiring module is further configured to acquire file preview data selected by the user from the at least one file preview data, and generate the file transmission indication according to at least one file preview data selected by the user, where the file transmission indication is used to indicate transmission The file data corresponding to at least one file preview data selected by the user.
  • a fourth aspect provides a data transmission apparatus, the apparatus comprising:
  • a second receiving module configured to receive a file preview request sent by the first terminal, where the file preview request is used to request previewing at least one file data stored by the data transmission device;
  • the second sending module is configured to send, according to the file preview request, at least one file preview data to the first terminal, where the file preview data can represent file data, and the size of each file preview data is smaller than the size of the corresponding file data.
  • the second receiving module is further configured to receive the first terminal to send a file transmission request; the file transmission request is generated by the first terminal based on a file transmission indication; and the file transmission indication is used to indicate transmission selection At least one file data characterized by the at least one file preview data;
  • the second sending module is further configured to send, according to the file transmission request, at least one file data indicated by the file transmission indication to the first terminal.
  • the second receiving module is further configured to receive a UDP broadcast message sent by the first terminal;
  • the device further includes: a second connection establishing module, configured to establish a first TCP connection and a second TCP connection with the first terminal, where the port numbers of the first TCP connection and the second TCP connection are different;
  • the second receiving module is further configured to receive the first through the first TCP connection. a file preview request sent by a terminal; receiving, by the first TCP connection, the first terminal to send a file transfer request;
  • the second sending module is further configured to send at least one file preview data to the first terminal by using the first TCP connection based on the file preview request; and based on the file transfer request and passing the second TCP
  • the connection transmits at least one file data indicated by the file transmission indication to the first terminal.
  • the apparatus further includes: a generating module, configured to generate, according to the file preview request, at least one file preview data that represents at least one file data.
  • the file preview data includes at least a thumbnail of the previewed file data
  • the file preview request includes a file type of the file data requesting the preview and a thumbnail size of the preview file;
  • the second sending module is further configured to send, to the first terminal, a file name, a file type, a file size, and thumbnail encoded data of the at least one previewed file data based on the file preview request.
  • the embodiment of the invention provides a data transmission method and device, and a storage medium.
  • the first terminal sends a file preview request to the second terminal, and receives the file preview data sent by the second terminal, so that the first terminal can select according to the file preview data.
  • the file data to be obtained is obtained, and the file data selected by the user is obtained from the second terminal, so that the file receiver can actively acquire the file, thereby improving the user experience.
  • FIG. 1 is a flowchart of Embodiment 1 of a data transmission method according to an embodiment of the present disclosure
  • Embodiment 2 is a flowchart of Embodiment 2 of a data transmission method according to an embodiment of the present invention
  • FIG. 3 is a flowchart of Embodiment 3 of a data transmission method according to an embodiment of the present disclosure
  • FIG. 4 is a schematic structural diagram of Embodiment 1 of a data transmission apparatus according to an embodiment of the present disclosure
  • FIG. 5 is a schematic structural diagram of Embodiment 2 of a data transmission apparatus according to an embodiment of the present disclosure
  • FIG. 6 is a schematic structural diagram of Embodiment 3 of a data transmission apparatus according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of Embodiment 4 of a data transmission apparatus according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of Embodiment 5 of a data transmission apparatus according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of Embodiment 6 of a data transmission apparatus according to an embodiment of the present invention.
  • terminal devices with wireless communication capabilities are being widely used, and terminal devices such as smart phones and tablet computers have gradually become an indispensable life and work tool for people.
  • terminal devices such as pictures and videos in communication
  • documents such as documents stored in the communication terminal device in the work.
  • the terminal device of the prior art only the terminal device storing the file actively initiates a file transfer request, and the file receiver can only passively receive.
  • file sharing methods are not flexible enough and the user experience is not good.
  • FIG. 1 is a flowchart of Embodiment 1 of a data transmission method according to an embodiment of the present invention. As shown in FIG. 1 , the data transmission method provided in this embodiment includes:
  • Step S101 The first terminal sends a file preview request to the second terminal, where the file preview request is used to request to preview at least one file data stored by the second terminal.
  • first terminal and second terminal two terminal devices that perform file data transmission are referred to as a first terminal and a second terminal, where the first terminal is a terminal device that requests to acquire file data, and the second terminal device stores file data.
  • Terminal Equipment The connection established between the first terminal and the second terminal may be any connection capable of file data transmission, such as TCP. Connection, or Wi-Fi direct connection, or mobile data connection.
  • the first terminal After the data transmission connection is established between the first terminal and the second terminal, the first terminal first sends a file preview request to the second terminal, where the file preview request is used to request previewing at least one file data stored by the second terminal. Since the file data stored in the second terminal may be more, and the files such as pictures and videos are generally large, the first terminal needs to selectively request the second terminal to send the file data required by the user. However, in this embodiment, the first terminal, that is, the receiving end of the file, is required to trigger the transmission of the file, but the first terminal and the user using the first terminal do not know which of the files stored in the second terminal are required by themselves. Therefore, the first terminal first needs to send a file preview request to the second terminal. The purpose of the file preview request is to pre-view the files stored in the second terminal to select the files to be transferred among the files stored in the second terminal.
  • the file preview request may request previewing all files stored in the second terminal, or may request previewing a portion of the files stored in the second terminal.
  • the file preview request may include attribute information of a file requesting preview, such as file type, file modification time, and the like.
  • the file type can be a picture, a video, a document, and the like. That is, the user using the first terminal can make the second terminal feed back different file preview data by configuring different file preview requests.
  • Step S102 The first terminal receives at least one file preview data sent by the second terminal, where the size of each file preview data is smaller than the size of the corresponding file data. That is, the first terminal receives at least one file preview data sent by the second terminal based on the file preview request, and the file preview data can represent file data, and the size of each file preview data is smaller than the corresponding file.
  • the size of the data
  • the second terminal parses the file, and knows which file data is required to be previewed by the first terminal, and generates a file that represents the file data of each required preview. Preview the data. Since the first terminal sends the file preview request for browsing the file data stored in the second terminal, and not for directly acquiring the data stored by the second terminal, the file preview data sent by the second terminal to the first terminal can be characterized. Second terminal The stored file data is also smaller in size than the data stored in the second terminal.
  • each file preview data includes partial data of file data stored in the corresponding second terminal, and the size of each file preview data is smaller than corresponding The size of the file data. It can be understood that the more data included in the file preview data, the more the corresponding file data can be reflected, but the size of the file preview data will increase accordingly. The larger the size of the file preview data, the longer the time required for the second terminal to send the file preview data to the first terminal, and the more network data traffic is occupied.
  • the first terminal can distinguish the file data that needs to be acquired after receiving the file preview data, and the size of the file preview data is as small as possible.
  • the first terminal can also specify the size of the required file preview data in the file preview request.
  • the size of the file preview data may be different for different types of file data, which will be described in detail in the following embodiments.
  • Step S103 The first terminal acquires a file transmission indication, where the file transmission indication is used to indicate that the at least one file data selected from the at least one file preview data is transmitted.
  • the first terminal After the first terminal receives the at least one file preview data sent by the second terminal, it can be known that the file data corresponding to the file preview data is stored in the second terminal. Further, the first terminal acquires a file transmission indication generated according to a preset rule or according to an instruction of the user, where the file transmission indication is used to indicate that the file data corresponding to the file preview data is selected from the at least one file preview data. Generally, the file transfer indication is input by the user according to the file preview data. When the user using the first terminal knows which file data is stored in the second terminal, the user using the first terminal can select the data through the file preview. Obtaining the file data, generating a file transmission indication, instructing the first terminal to obtain the file data selected by the user from the second terminal.
  • Step S104 The first terminal sends a file transmission request generated based on the file transmission indication to the second terminal.
  • the first terminal After acquiring the file transmission indication input by the user, the first terminal generates a file transmission request, and sends the file transmission request to the second terminal, where the file transmission request is used to request the second terminal to send at least the indication indicated by the file transmission indication.
  • a file of data A file of data.
  • Step S105 The first terminal receives the at least one file data indicated by the file transmission indication sent by the second terminal according to the file transmission request.
  • the second terminal may send the file data indicated in the file transfer request to the first terminal.
  • the file data here is the complete file data.
  • the first terminal sends the file preview request to the second terminal, and receives the file preview data sent by the second terminal, so that the first terminal can select the file data to be acquired according to the file preview data. And obtaining the file data selected by the user from the second terminal, so that the file receiver can actively acquire the file, thereby improving the user experience.
  • any data transmission connection can be established between the first terminal and the second terminal to implement data transmission.
  • Data can be transferred over a TCP connection.
  • the TCP connection is a connection applied to a local area network, and data transmission through a TCP connection is relatively reliable, and the transmission rate is high.
  • TCP connection can also be established through Wi-Fi Direct connection, which is similar to the method of establishing a TCP connection through a local area network.
  • the first terminal and the second terminal can perform UDP broadcast, and the first terminal and the second terminal can learn the existence of the other party through the UDP packets broadcasted by each other, thereby establishing a TCP connection.
  • the TCP connection here may be a TCP socket connection, wherein the TCP socket connection includes a source network protocol (IP) address, a destination IP address, a source port number, and a destination port number, and the TCP socket connection is based on TCP. Standard connection.
  • IP source network protocol
  • the two transmissions of the data and the file data are performed, so that two TCP connections can be established between the first terminal and the second terminal, which are respectively referred to as a first TCP connection and a second TCP connection.
  • the port numbers used by the first TCP connection and the second TCP connection are different and have been distinguished.
  • the first terminal sends a file preview request to the second terminal through the first TCP connection; and receives file preview data sent by the second terminal by using the first TCP connection; and sends a file transfer request to the second terminal by using the first TCP connection.
  • Receiving at least one file data sent by the second terminal through the second TCP connection that is, the first TCP connection is used to transmit messages and the second TCP connection is used to transmit data.
  • connection established between the first terminal and the second terminal is not limited to a TCP connection.
  • a server-client connection is established between the first terminal and the second terminal, and the data transmission method shown in FIG. 1 can also be completed.
  • the second terminal as the data transmitting end serves as a server
  • the first terminal as the data receiving end serves as a client.
  • the first terminal sends the file preview request and the received file preview data may adopt a JavaScript Object Notation (JSON) protocol, and the first terminal may send any file transfer request and receive file data using any protocol suitable for file transfer.
  • JSON JavaScript Object Notation
  • the data transmission method provided by the embodiment of the present invention does not limit the foregoing protocol, and any other transmission protocol may be used for data transmission between the first terminal and the second terminal.
  • the first terminal Due to the large number of files stored in the terminal device, the first terminal generally does not request the second terminal to send file preview data of all files stored by the second terminal. Therefore, the file preview request sent by the first terminal can define the attribute of the file preview data that needs to be acquired.
  • the file preview request sent by the first terminal includes a file type for requesting preview, and the file type herein may be any one or more of a picture, a video, and a document. Then, after the second terminal receives the file preview request, the stored file is filtered, and only the file preview data of the corresponding type is sent to the first terminal.
  • the file preview request sent by the first terminal includes other attributes such as the modification time and size of the file requesting the preview, and the second terminal filters out the suitable file after receiving the file preview request, and sends the corresponding file to the first terminal. Preview the data.
  • the file preview data sent by the second terminal to the first terminal may also be in various forms, such as a file name, a thumbnail, or the like of the previewed file data.
  • the file preview data is a preview of the file data (hereinafter referred to as a preview file)
  • the file preview request sent by the first terminal to the second terminal may include the type of the preview file and the size of the thumbnail of the preview file, for example,
  • the type of the preview file requested is a picture
  • the thumbnail size is 80 ⁇ 80 pixels
  • the type of the preview file is requested to be a video
  • the thumbnail size is 100 ⁇ 100 pixels.
  • the thumbnail of the preview file is to compress the corresponding picture file to the size specified by the thumbnail size, but the image in the thumbnail is the same as the original picture file.
  • the thumbnail of the preview file may be a thumbnail of the preview file by compressing any frame image of the video file to a size specified by the thumbnail size.
  • the first of the video files may be The frame image is compressed to the size specified by the thumbnail size as a thumbnail of the preview file.
  • the thumbnail of the preview file may be a size of a thumbnail of the preview file by compressing any page image of the document into a thumbnail size.
  • the first page image of the document may be Compress the size specified for the thumbnail size as a thumbnail of the preview file.
  • the first terminal can receive a plurality of file preview data, wherein each file preview data includes a name of the preview file, a file type, a file size, and thumbnail encoded data.
  • the first terminal decodes the received thumbnail encoded data to obtain a corresponding thumbnail.
  • the first terminal may also be in the At least one file preview data obtained is displayed on the display.
  • the user can browse a plurality of file preview data on the display screen of the first terminal, select a file preview data to be acquired, and generate a file transfer instruction.
  • the file preview data as a thumbnail of the preview file as an example
  • the first terminal receives the thumbnails of the plurality of preview files, By sequentially arranging a plurality of thumbnails on the display screen, the user can visually see a plurality of files stored by the second terminal.
  • the user can select a thumbnail corresponding to the desired file through the touch screen.
  • the user can also select the thumbnail corresponding to the obtained file by using the control button of the first terminal.
  • the user can select the corresponding thumbnail by voice input, gesture input, and the like.
  • the embodiment of the present invention further describes a first type of computer storage medium.
  • the first type of computer storage medium stores a computer program for performing the data transmission method shown in FIG. 1 in the embodiment of the present invention.
  • FIG. 2 is a flowchart of Embodiment 2 of a data transmission method according to an embodiment of the present invention. As shown in FIG. 2, the data transmission method provided in this embodiment includes:
  • Step S201 The second terminal receives a file preview request sent by the first terminal, where the file preview request is used to request to preview at least one file data stored by the second terminal.
  • Step S202 The second terminal sends at least one file preview data to the first terminal according to the file preview request, where the file preview data can represent file data, and the size of each file preview data is smaller than the corresponding file data. size.
  • Step S203 the second terminal receives the first terminal to send a file transmission request, and the file transmission request is used to request the second terminal to transmit at least one file data; specifically, the second terminal receives the first terminal to send a file transmission request;
  • the file transfer request is generated by the first terminal based on a file transfer indication; the file transfer indication is used to indicate that at least one file data selected from the at least one file preview data is transmitted.
  • Step S204 The second terminal sends the at least one file data to the first terminal. Specifically, the second terminal sends the at least one file indicated by the file transmission indication to the first terminal according to the file transmission request. data.
  • the data transmission method provided in this embodiment uses the second terminal as the file data sender as the execution subject, but the processing performed by the second terminal has been described in detail in the embodiment shown in FIG. I will not go into details here.
  • the second terminal needs to receive the UDP broadcast message sent by the first terminal before receiving the file preview request sent by the first terminal, thereby A TCP connection is established between the second terminal and the first terminal.
  • the process and method for establishing a TCP connection between the second terminal and the first terminal have been described in detail in the foregoing embodiments, and details are not described herein again.
  • the second terminal after receiving the file preview request sent by the first terminal, the second terminal further needs to generate at least one file preview data according to the information indicated in the file preview request.
  • the file preview request received by the second terminal may define an attribute of the file preview data that needs to be acquired.
  • the file preview request includes a file type for requesting preview, and the file type here may be any one or more of a picture, a video, and a document.
  • the second terminal receives the file preview request, the stored file will be filtered to generate only the file preview data of the corresponding type.
  • the file preview request includes other attributes such as the modification time and size of the file requesting the preview.
  • the second terminal will filter out the suitable file and generate only the corresponding file preview data.
  • the file preview data generated by the second terminal may be in various forms, such as a file name, a thumbnail, and the like of the preview file.
  • the file preview request sent by the first terminal to the second terminal may include requesting the type of the preview file and the size of the thumbnail of the preview file, for example, requesting the type of the preview file as a picture.
  • the thumbnail size is 80 ⁇ 80 pixels, or the type of the preview file is requested to be a video, and the thumbnail size is 100 ⁇ 100 pixels.
  • the second terminal receives the file preview request, the corresponding type of file data is filtered out, and the file data is encoded into thumbnails of corresponding sizes.
  • the thumbnail of the preview file is to compress the corresponding picture file to the size specified by the thumbnail size, but the image in the thumbnail is the same as the original picture file.
  • the thumbnail of the preview file may be a thumbnail of the preview file by compressing any frame image of the video file to a size specified by the thumbnail size.
  • the thumbnail may be viewed.
  • the first frame image of the frequency file is compressed to the size specified by the thumbnail size as a thumbnail of the preview file.
  • the thumbnail of the preview file may be a size of a thumbnail of the preview file by compressing any page image of the document into a thumbnail size.
  • the first page image of the document may be Compress the size specified for the thumbnail size as a thumbnail of the preview file.
  • the first terminal can receive a plurality of file preview data, wherein each file preview data includes a name of the preview file, a file type, a file size, and thumbnail encoded data.
  • the first terminal decodes the received thumbnail encoded data to obtain a corresponding thumbnail.
  • the embodiment of the present invention further describes a second type of computer storage medium.
  • the second type of computer storage medium stores a computer program for performing the data transmission method shown in FIG. 2 in the embodiment of the present invention.
  • FIG. 3 is a flowchart of Embodiment 3 of a data transmission method according to an embodiment of the present invention. As shown in FIG. 3, the data transmission method provided in this embodiment includes:
  • Step S301 a TCP connection is established between the first terminal and the second terminal.
  • the first terminal and the second terminal establish a TCP connection in the same local area network as an example.
  • a UDP broadcast is required between the first terminal and the second terminal, and the other party is discovered through the UDP packets broadcasted by each other.
  • the establishment of a TCP connection where the TCP connection can be a TCP socket connection.
  • two TCP connections can be established at the same time, wherein the first TCP connection is used to transmit a file preview request, a file preview data, and a file transfer request, and the first TCP connection can adopt a JSON protocol format.
  • the second TCP connection is used to transfer file data.
  • the first TCP connection and the second TCP connection use different port numbers.
  • Step S302 the first terminal sends a thumbnail to the second terminal by using the first TCP connection. begging.
  • the file preview data is taken as a thumbnail of the preview file, and then the file preview request sent by the first terminal to the second terminal is actually a thumbnail sending request.
  • the thumbnail send request can be in the JSON protocol format, including the file type and thumbnail size of the request preview.
  • the file preview request may be, for example: ⁇ "MSGType”: “1”, “FileType”: “Video”, “Size”: “80x80” ⁇ .
  • MSGType indicates the type of information
  • a value of "1” indicates that this information is a file preview request.
  • “FileType” indicates the file type
  • “Video” indicates that the file type is video.
  • “Size” indicates the file size
  • “80x80” indicates that the thumbnail size is 80x80 pixels.
  • Step S303 the second terminal generates thumbnail preview data.
  • the second terminal parses the thumbnail sending file to obtain the thumbnail file type and size required by the first terminal. Then, a thumbnail of the corresponding file data is obtained through a system application code interface (API). The obtained thumbnail image is encoded to obtain thumbnail encoded data, and the encoding here may be any encoding method, such as Bsse64 encoding. Finally, the thumbnail file encoding data, file name, file size and other information are converted into a JSON protocol format to generate thumbnail preview data.
  • API system application code interface
  • the file preview data generated by the second terminal may be, for example: ⁇ "MSGType”: “2", “FileList”: [ ⁇ "FileName”: “video1.mp4", “FileIndex”: “1”, “FileType”: “ Video”, “FileSize”: “24258654”, “ThumbnailData”: “Thumbnail Base64 encoded data” ⁇ , ⁇ "FileName”: “video2.mp4", "FileIndex”: “2”, “FileType”: “Video” “FileSize”: “247585684", "ThumbnailData”: “Thumbnail Base64 encoded data” ⁇ ...] ⁇ .
  • “MSGType” indicates the type of information
  • a value of "2" indicates that this information is file preview data.
  • “FileList” indicates a file list. Since the file preview request sent by the first terminal requests one type of file preview data, and the second terminal may have a plurality of file data of a corresponding type, the file generated by the second terminal Multiple files will be included in the preview data The file preview data corresponding to the data.
  • "FileName” indicates the file name, and the values "video1.mp4" and “video2.mp4" indicate the name of the file data.
  • “FileIndex” represents a file index, and its values "1" and "2" indicate the sorting of file preview data in the list.
  • “FileType” indicates the file type, and its value “Video” indicates that the file type is video.
  • “FileSize” indicates the size of the file, and the values “24258654” and “247585684" indicate the number of bytes occupied by the file data.
  • “ThumbnailData” indicates thumbnail file data whose data "thumbnail Base64 encoded data” is filled with the data encoded by the thumbnail file.
  • Step S304 the second terminal sends the thumbnail preview data to the first terminal.
  • the second terminal sends the thumbnail preview data to the first terminal through the first TCP connection.
  • Step S305 the first terminal decodes the thumbnail preview data, and displays the thumbnail preview data to the user.
  • the first terminal acquires a thumbnail of each file data pair and displays it to the user on the display screen.
  • the user can know that the thumbnail is from the second terminal.
  • Step S306 the first terminal acquires a file transmission indication input by the user.
  • the user can select a thumbnail corresponding to the file data to be acquired by dragging, clicking, or the like on the display screen of the first terminal.
  • the user can also select the corresponding thumbnail by voice input, gesture input, and the like.
  • the thumbnail selected by the user is a file transmission indication input by the user, and the file transmission indicates that the user instructs the first terminal to acquire file data corresponding to the thumbnail selected by the user.
  • Step S307 the first terminal sends a file transmission request to the second terminal.
  • the first terminal sends a file transmission request to the second terminal by using the first TCP connection, and the file transmission request may be in a JSON protocol format.
  • the file transfer request may be, for example: ⁇ "MSGType”: “3", “FileList”: [ ⁇ "FileName”: “video1.mp4", “FileIndex”: “1”, “FileType”: “Video” “FileSize” : “24258654” ⁇ ] ⁇ .
  • MSGType indicates the type of information
  • a value of "3” indicates that the information is a file transfer request.
  • "FileList” represents a list of files, and the user may need to obtain a second end A plurality of file data stored in the end, so the file transfer request may include a transfer request of a plurality of file data, which is represented by a file list.
  • FileName indicates the file name
  • video1.mp4 indicates the name of the file data
  • FileIndex represents a file index whose value "1” indicates the sorting of the file preview data in the list.
  • FileType indicates the file type
  • Video indicates that the file type is video.
  • FileSize indicates the size of the file, and its value “24258654” indicates the number of bytes occupied by the file data.
  • Step S308 the second terminal sends the file data to the first terminal.
  • the second terminal determines the file data that the first terminal needs to acquire, and sends the file data to the first terminal through the second TCP connection.
  • the second terminal may send the file data to the first terminal by using the following protocol format: ⁇ HeadFlag> ⁇ NameLength> ⁇ Name> ⁇ Filesize> ⁇ Stream>.
  • ⁇ HeadFlag> is the packet header, occupying 4 bytes, and its value is 0xFFFFFFFF indicating the packet header.
  • ⁇ NameLength> is 1 byte, which is the length of the file character name.
  • ⁇ Name> is an N-byte file name.
  • ⁇ Filesize> is 8 bytes, indicating the file data size.
  • ⁇ Stream> is the file data stream.
  • FIG. 4 is a schematic structural diagram of Embodiment 1 of a data transmission apparatus according to an embodiment of the present invention. As shown in FIG. 4, the data transmission apparatus provided in this embodiment includes:
  • the first sending module 41 is configured to send a file preview request to the second terminal, where the file preview request is used to request previewing at least one file data stored by the second terminal.
  • the first receiving module 42 is configured to receive at least one file preview data that is sent by the second terminal according to the file preview request, where the file preview data can represent file data, and the size of each file preview data is smaller than the corresponding file. The size of the data.
  • the obtaining module 43 is configured to obtain a file transfer indication input by the user, where the file transfer indication is used to indicate that the at least one file data selected from the at least one file preview data is transmitted.
  • the first sending module 41 is further configured to send, according to the file transmission finger, the second terminal The file transfer request generated.
  • the first receiving module 42 is further configured to receive the at least one file data indicated by the file transmission indication sent by the second terminal according to the file transmission request.
  • the user of the data transmission device provided in this embodiment implements the processing of the data transmission method shown in FIG. 1 , and the implementation principle and technical effects thereof are similar, and details are not described herein again.
  • FIG. 5 is a schematic structural diagram of Embodiment 2 of a data transmission apparatus according to an embodiment of the present invention. As shown in FIG. 5, the data transmission apparatus provided in this embodiment further includes: a first connection establishment module 51.
  • the first receiving module 42 is further configured to receive the UDP broadcast message sent by the second terminal.
  • the first connection establishing module 51 is configured to establish a first TCP connection and a second TCP connection with the second terminal, where the port numbers of the first TCP connection and the second TCP connection are different.
  • the first sending module 41 is further configured to send the file preview request to the second terminal by using the first TCP connection; and send, according to the file transmission indication, the second terminal by using the first TCP connection.
  • the generated file transfer request is further configured to send the file preview request to the second terminal by using the first TCP connection; and send, according to the file transmission indication, the second terminal by using the first TCP connection.
  • the first receiving module 42 is further configured to receive, by using the first TCP connection, at least one file preview data that is sent by the second terminal based on the file preview request; and receive the second by using the second TCP connection.
  • the file preview data includes at least a thumbnail of the previewed file data;
  • the file preview request includes a file type and a thumbnail size of the file data requesting the preview.
  • the file type includes at least one of a picture, a video, and a document;
  • the first receiving module 42 is further configured to receive a file name and a file of the file data of the at least one preview sent by the second terminal based on the file preview request.
  • Type, file size, and thumbnail encoded data are examples of the file data.
  • FIG. 6 is a schematic structural diagram of Embodiment 3 of a data transmission apparatus according to an embodiment of the present disclosure, such as As shown in FIG. 6, the data transmission apparatus provided in this embodiment further includes, on the basis of FIG. 5, a display module 61 configured to display the at least one file preview data to a user.
  • the obtaining module 43 is further configured to acquire file preview data selected by the user from the at least one file preview data, and generate the file transmission indication according to at least one file preview data selected by the user, where the file transmission indication is used to indicate the transmission user The file data corresponding to at least one of the selected file preview data.
  • FIG. 7 is a schematic structural diagram of Embodiment 4 of a data transmission apparatus according to an embodiment of the present invention. As shown in FIG. 7, the data transmission apparatus provided in this embodiment includes:
  • the second receiving module 71 is configured to receive a file preview request sent by the first terminal, where the file preview request is used to request previewing at least one file data stored by the data transmission device.
  • the second sending module 72 is configured to send, according to the file preview request, at least one file preview data to the first terminal, where the file preview data can represent file data, and the size of each file preview data is smaller than the corresponding file data. size.
  • the second receiving module 71 is further configured to receive, by the first terminal, a file transmission request, where the file transmission request is generated by the first terminal based on a file transmission indication, and the file transmission indication is used to indicate that the transmission is selected At least one file data represented by the at least one file preview data.
  • the second sending module 72 is further configured to be configured to send, according to the file transmission request, at least one file data indicated by the file transmission indication to the first terminal.
  • the user of the data transmission device provided in this embodiment implements the processing of the data transmission method shown in FIG. 2, and the implementation principle and technical effects thereof are similar, and details are not described herein again.
  • FIG. 8 is a schematic structural diagram of Embodiment 5 of a data transmission apparatus according to an embodiment of the present invention. As shown in FIG. 8, the data transmission apparatus provided in this embodiment further includes: a second connection establishment module 81.
  • the second receiving module 71 is further configured to receive the UDP broadcast message sent by the first terminal.
  • the second connection establishing module 81 is configured to establish a first TCP connection and a second TCP connection with the first terminal, where the port numbers of the first TCP connection and the second TCP connection are different.
  • the second receiving module 71 is further configured to receive, by using the first TCP connection, a file preview request sent by the first terminal, and receive, by using the first TCP connection, the first terminal to send a file transfer request.
  • the second sending module 72 is further configured to send at least one file preview data to the first terminal by using the first TCP connection based on the file preview request; and based on the file transfer request and through the second TCP connection Transmitting, to the first terminal, at least one file data indicated by the file transmission indication.
  • FIG. 9 is a schematic structural diagram of Embodiment 6 of a data transmission apparatus according to an embodiment of the present invention.
  • the data transmission apparatus provided in this embodiment further includes: a generating module 91 configured to be configured according to FIG.
  • the file preview request generates at least one file preview data characterizing at least one file data.
  • the file preview data includes at least a thumbnail of the previewed file data.
  • the file preview request includes a file type of a file data requesting preview and a thumbnail size of a preview file, the file type including at least one of a picture, a video, and a document.
  • the second sending module 72 is further configured to send, to the first terminal, a file name, a file type, a file size, and thumbnail encoded data of the at least one previewed file data based on the file preview request.
  • the first sending module 41 and the second sending module 72 may be implemented by a transmitter or a transceiver; the first receiving module 42 and the second receiving module 71 may be implemented by a receiver or a transceiver;
  • the module 43, the first connection establishing module 51, the second connection establishing module 81, and the generating module 91 may be a Central Processing Unit (CPU), a Micro Processor Unit (MPU), and a digital signal processor (Digital). Signal Processor, DSP) or Field Programmable Gate Array (Field Programmable Gate Array, FPGA) and other implementations.
  • Display module 61 can be implemented by a display.
  • the embodiment of the present invention further provides a terminal device.
  • the first sending module 41 and the second sending module 72 may be a transmitter or a transceiver in the terminal device;
  • Module 42 and second receiving module 71 may be receivers or transceivers in the terminal device.
  • the obtaining module 43, the first connection establishing module 51, the second connection establishing module 81, and the generating module 91 can be implemented by a CPU, an MPU, a DSP, an FPGA, or the like of the terminal device.
  • the display module 61 can be implemented by a display of the terminal device.
  • the terminal device further includes a memory configured to store the program code, and the processor calls the program code stored in the memory to implement the data transmission method provided by the embodiment of the present invention.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the device is implemented in a flow chart A function specified in a block or blocks of a process or multiple processes and/or block diagrams.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • the first terminal sends the file preview request to the second terminal, and receives the file preview data sent by the second terminal, so that the first terminal can select the file data to be acquired according to the file preview data, and from the second terminal.
  • the file data selected by the user is obtained, so that the file receiver can actively acquire the file, thereby improving the user experience.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例公开了一种数据传输方法及装置、存储介质,包括:第一终端向第二终端发送文件预览请求,所述文件预览请求用于请求预览第二终端存储的至少一个文件数据;所述第一终端接收第二终端基于文件预览请求而发送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;所述第一终端获取文件传输指示,所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;所述第一终端向所述第二终端发送基于所述文件传输指示而生成的文件传输请求;所述第一终端接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。

Description

一种数据传输方法及装置、存储介质
相关申请的交叉引用
本申请基于申请号为201610556382.5、申请日为2016年07月18日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本发明涉及通信领域,尤其涉及一种数据传输方法及装置、存储介质。
背景技术
目前,一些终端设备的应用中有在局域网环境下分享文件或通过无线保真(Wireless-Fidelity,Wi-Fi)直连分享文件的功能,从而使用户间能够便捷地分享文件,且无需耗费数据流量。
终端设备中通过局域网或Wi-Fi直连分享文件的基本流程为:1)使两个安装有同一应用的终端设备处于同一局域网内,或两个安装有同一应用的终端设备通过Wi-Fi进行直连;2)用户在作为发送方的终端设备本地存储的文件中选择一个或多个需要发送的文件,并点击发送按钮;3)作为接收方的终端设备被动接收发送方的文件。
从上述处理过程可以看出,作为接收方的终端设备仅能被动接收文件,用户体验不好。
发明内容
为解决上述技术问题,本发明实施例期望提供一种数据传输方法及装置、存储介质,使文件接收方能够主动获取文件,提高了用户体验。
本发明实施例的技术方案是这样实现的:
第一方面提供一种数据传输方法,所述方法包括:
第一终端向第二终端发送文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据;
所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
所述第一终端获取文件传输指示,所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
所述第一终端向所述第二终端发送基于所述文件传输指示而生成的文件传输请求;
所述第一终端接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
在第一方面一种可能的实现方式中,所述第一终端向第二终端发送文件预览请求之前,所述方法还包括:
所述第一终端接收所述第二终端发送的用户数据报文协议(User Datagram Protocol,UDP)广播消息;
所述第一终端与所述第二终端建立第一传输控制协议(Transmission Control Protocol,TCP)连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
对应地,所述第一终端向第二终端发送文件预览请求,包括:
所述第一终端通过所述第一TCP连接向所述第二终端发送所述文件预览请求;
对应地,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,包括:
所述第一终端通过所述第一TCP连接接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据;
对应地,所述第一终端向所述第二终端发送基于所述文件传输指示而生成的文件传输请求,包括:
所述第一终端通过所述第一TCP连接向所述第二终端发送基于所述文件传输指示而生成的所述文件传输请求;
对应地,所述第一终端接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据,包括:
所述第一终端通过所述第二TCP连接接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
在第一方面一种可能的实现方式中,所述文件预览数据至少包括预览的文件数据的缩略图;
所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸;
对应地,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,包括:
所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
在第一方面一种可能的实现方式中,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据之后,所述方法还包括:
所述第一终端向用户显示所述至少一个文件预览数据;
对应地,所述第一终端获取文件传输指示,包括:
所述第一终端获取用户从所述至少一个文件预览数据中选择的文件预览数据,基于用户选择的至少一个文件预览数据生成所述文件传输指示, 所述文件传输指示用于指示传输用户选择的至少一个文件预览数据所对应的文件数据。
第二方面提供一种数据传输方法,所述方法包括:
第二终端接收第一终端发送的文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据;
所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
所述第二终端接收所述第一终端发送文件传输请求;所述文件传输请求是所述第一终端基于文件传输指示而生成的;所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
所述第二终端基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
在第二方面一种可能的实现方式中,所述第二终端接收第一终端发送的文件预览请求之前,所述方法还包括:
所述第二终端接收所述第一终端发送的UDP广播消息;
所述第二终端与所述第一终端建立第一TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
对应地,所述第二终端接收第一终端发送的文件预览请求,包括:
所述第二终端通过所述第一TCP连接接收第一终端发送的文件预览请求;
对应地,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,包括:
所述第二终端基于所述文件预览请求并通过所述第一TCP连接向所述第一终端发送至少一个文件预览数据;
对应地所述第二终端接收所述第一终端发送文件传输请求,包括:
所述第二终端通过所述第一TCP连接接收所述第一终端发送文件传输请求;
对应地,所述第二终端基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据,包括:
所述第二终端基于所述文件传输请求并通过所述第二TCP连接向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
在第二方面一种可能的实现方式中,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据之前,所述方法还包括:
所述第二终端根据所述文件预览请求生成表征至少一个文件数据的至少一个文件预览数据。
在第二方面一种可能的实现方式中,所述文件预览数据至少包括预览的文件数据的缩略图;
所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸;
对应地,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,包括:
所述第二终端基于所述文件预览请求向所述第一终端发送至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
第三方面提供一种数据传输装置,所述装置包括:
第一发送模块,配置为向第二终端发送文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据;
第一接收模块,配置为接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
获取模块,配置为获取用户输入的文件传输指示,所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
所述第一发送模块,还配置为向所述第二终端发送基于所述文件传输指示而生成的文件传输请求;
所述第一接收模块,还配置为接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
在第三方面一种可能的实现方式中,所述第一接收模块,还配置为接收所述第二终端发送的UDP广播消息;
所述装置还包括:第一连接建立模块,配置为与所述第二终端建立第一TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
对应地,所述第一发送模块,还配置为通过所述第一TCP连接向所述第二终端发送所述文件预览请求;通过所述第一TCP连接向所述第二终端发送基于所述文件传输指示而生成的所述文件传输请求;
所述第一接收模块,还配置为通过所述第一TCP连接接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据;通过所述第二TCP连接接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
在第三方面一种可能的实现方式中,所述文件预览数据至少包括预览的文件数据的缩略图;
所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸;
对应地,所述第一接收模块,还配置为接收所述第二终端基于所述文件预览请求而发送的至少一个预览的文件数据的文件名称、文件类型、文 件大小和缩略图编码数据。
在第三方面一种可能的实现方式中,所述装置还包括:显示模块,配置为向用户显示所述至少一个文件预览数据;
所述获取模块,还配置为获取用户从所述至少一个文件预览数据中选择的文件预览数据,基于用户选择的至少一个文件预览数据生成所述文件传输指示,所述文件传输指示用于指示传输用户选择的至少一个文件预览数据所对应的文件数据。
第四方面提供一种数据传输装置,所述装置包括:
第二接收模块,配置为接收第一终端发送的文件预览请求,所述文件预览请求用于请求预览所述数据传输装置存储的至少一个文件数据;
第二发送模块,配置为基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
所述第二接收模块,还配置为接收所述第一终端发送文件传输请求;所述文件传输请求是所述第一终端基于文件传输指示而生成的;所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
所述第二发送模块,还配置为基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
在第四方面一种可能的实现方式中,所述第二接收模块,还配置为接收所述第一终端发送的UDP广播消息;
所述装置还包括:第二连接建立模块,配置为与所述第一终端建立第一TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
对应地,所述第二接收模块,还配置为通过所述第一TCP连接接收第 一终端发送的文件预览请求;通过所述第一TCP连接接收所述第一终端发送文件传输请求;
所述第二发送模块,还配置为基于所述文件预览请求并通过所述第一TCP连接向所述第一终端发送至少一个文件预览数据;基于所述文件传输请求并通过所述第二TCP连接向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
在第四方面一种可能的实现方式中,所述装置还包括:生成模块,配置为根据所述文件预览请求生成表征至少一个文件数据的至少一个文件预览数据。
在第四方面一种可能的实现方式中,所述文件预览数据至少包括预览的文件数据的缩略图;
所述文件预览请求包括请求预览的文件数据的文件类型和预览文件缩略图尺寸;
所述第二发送模块,还配置为基于所述文件预览请求向所述第一终端发送至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
本发明实施例提供了一种数据传输方法及装置、存储介质,第一终端通过向第二终端发送文件预览请求,接收第二终端发送的文件预览数据,使第一终端能够根据文件预览数据选择所需获取的文件数据,并从第二终端获取用户选择的文件数据,使文件接收方能够主动获取文件,提高了用户体验。
附图说明
图1为本发明实施例提供的数据传输方法实施例一的流程图;
图2为本发明实施例提供的数据传输方法实施例二的流程图;
图3为本发明实施例提供的数据传输方法实施例三的流程图;
图4为本发明实施例提供的数据传输装置实施例一的结构示意图;
图5为本发明实施例提供的数据传输装置实施例二的结构示意图;
图6为本发明实施例提供的数据传输装置实施例三的结构示意图;
图7为本发明实施例提供的数据传输装置实施例四的结构示意图;
图8为本发明实施例提供的数据传输装置实施例五的结构示意图;
图9为本发明实施例提供的数据传输装置实施例六的结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。
随着无线通信的普及,各种具有无线通信能力的终端设备正在被广泛使用,例如智能手机、平板电脑等终端设备逐渐成为人们不可或缺的生活、工作工具。为了增进感情,人们很乐于在交流中彼此分享图片、视频等终端设备中存储的文件,在工作中也可能有交流终端设备中存储的文档等文件。而现有技术的终端设备中,仅能是存储有文件的终端设备主动发起文件传输请求,而文件接收方仅能被动接收。这样的文件分享方式不够灵活,用户体验不佳。
图1为本发明实施例提供的数据传输方法实施例一的流程图,如图1所示,本实施例提供的数据传输方法包括:
步骤S101,第一终端向第二终端发送文件预览请求,文件预览请求用于请求预览第二终端存储的至少一个文件数据。
首先,若需在两个终端设备间传输文件数据,需要两个终端设备之间建立有数据传输连接。在本实施例中,将进行文件数据传输的两个终端设备称为第一终端和第二终端,其中第一终端为请求获取文件数据的终端设备,而第二终端设备为存储有文件数据的终端设备。第一终端和第二终端之间所建立的连接可以是任一种能够进行文件数据传输的连接,例如TCP 连接,或者Wi-Fi直连,或者移动数据连接等。
当第一终端和第二终端之间建立了数据传输连接后,第一终端首先向第二终端发送文件预览请求,该文件预览请求用于请求预览第二终端存储的至少一个文件数据。由于第二终端中存储的文件数据可能较多,并且如图片、视频等文件一般较大,因此第一终端需要有选择地请求第二终端发送用户所需的文件数据。而由于本实施例中需要由第一终端,也就是文件的接收端来触发文件的传输,但第一终端及使用第一终端的用户不清楚第二终端中存储的文件中哪些是自己需要的,因此,第一终端首先需要向第二终端发送文件预览请求。文件预览请求的目的是预先浏览第二终端中所存储的文件,以便在第二终端中存储的文件中选择所需传输的文件。
文件预览请求可以请求预览第二终端中存储的所有文件,也可以请求预览第二终端中存储的部分文件。文件预览请求中可以包括请求预览的文件的属性信息,例如文件类型、文件修改时间等。其中文件类型可以是图片、视频、文档等类型。也即使用第一终端的用户可以通过配置不同的文件预览请求,使第二终端反馈不同的文件预览数据。
步骤S102,第一终端接收第二终端发送的至少一个文件预览数据,每个文件预览数据的大小小于对应的文件数据的大小。也即,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
具体地,当第二终端接收到第一终端发送的文件预览请求后,将对其进行解析,获知第一终端所需预览的文件数据是哪些,并生成表征各所需预览的文件数据的文件预览数据。由于第一终端发送文件预览请求是为了浏览第二终端中存储的文件数据,并不是为了直接获取第二终端所存储的数据,因此第二终端向第一终端发送的文件预览数据要能够表征第二终端 所存储的文件数据,并且大小还要小于第二终端中所存储的数据。
那么每个第一终端所需预览的文件数据均对应一个文件预览数据,每个文件预览数据包括其对应的第二终端中存储的文件数据的部分数据,并且每个文件预览数据的大小小于对应的文件数据的大小。可以理解的是,文件预览数据中所包括的数据越多,越能够体现出其对应的文件数据,但文件预览数据的大小将相应增大。文件预览数据的大小越大,那么第二终端向第一终端发送文件预览数据所需时间越长,占用网络数据流量越多。因此,需要找到文件预览数据与其对应的文件数据的合理比例,以保证第一终端在接收到文件预览数据后,用户能够分辨出所需获取的文件数据,且文件预览数据的大小尽可能小。或者第一终端还可以在文件预览请求中指定所需的文件预览数据的大小。当然,对于不同类型的文件数据,其文件预览数据的大小可以有所不同,在下述实施例中将进行详细说明。
步骤S103,第一终端获取文件传输指示,文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据。
当第一终端接收到第二终端发送的至少一个文件预览数据后,即可获知第二终端中存储有与这些文件预览数据对应的文件数据。进一步地,第一终端获取到根据预设的规则或根据用户的指示所生成的文件传输指示,该文件传输指示用于指示传输从至少一个文件预览数据中选择文件预览数据所对应的文件数据。一般地,文件传输指示是用户根据文件预览数据输入的,当使用第一终端的用户获知第二终端中存储的文件数据分别是哪些时,那么使用第一终端的用户可以通过文件预览数据选择需要获取的文件数据,生成文件传输指示,指示第一终端向第二终端去获取用户选择的文件数据。
步骤S104,第一终端向第二终端发送基于所述文件传输指示而生成的文件传输请求。
第一终端在获取到用户输入的文件传输指示后,生成文件传输请求,并将该文件传输请求发送至第二终端,文件传输请求用于请求第二终端发送所述文件传输指示所指示的至少一个文件数据。
步骤S105,所述第一终端接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
当第二终端接收到文件传输请求后,即可将文件传输请求中所指示传输的文件数据发送至第一终端。这里的文件数据为完整的文件数据。
本实施例提供的数据传输方法中,第一终端通过向第二终端发送文件预览请求,接收第二终端发送的文件预览数据,使第一终端能够根据文件预览数据选择所需获取的文件数据,并从第二终端获取用户选择的文件数据,使文件接收方能够主动获取文件,提高了用户体验。
在图1所示实施例中,第一终端和第二终端之间可以建立任一种数据传输连接,实现数据传输。但考虑到用户在两个终端设备之间进行数据传输时,一般都是当两个终端设备距离较近时进行的,那么为了提高数据传输速度,节约网络资源及费用,在两个终端设备之间可以通过TCP连接进行数据传输。TCP连接是一种应用于局域网的连接,通过TCP连接进行数据传输较为可靠,且传输速率较高。另外,两个终端设备若都具有Wi-Fi连接能力,那么还可以通过Wi-Fi直连建立TCP连接,这与通过局域网建立TCP连接的方法类似。
在终端设备之间建立TCP连接之前,还需要有相互发现的过程。第一终端和第二终端可以进行UDP广播,第一终端和第二终端可以通过相互广播的UDP报文获知对方的存在,从而建立TCP连接。这里的TCP连接可以是TCP套接字连接,其中TCP套接字连接包括源网络协议(Internet Protocol,IP)地址、目标IP地址、源端口号和目标端口号,TCP套接字连接是基于TCP的标准连接。由于第一终端和第二终端之间需要进行文件预 览数据和文件数据的两次传输,因此可以在第一终端和第二终端之间建立两个TCP连接,分别称为第一TCP连接和第二TCP连接。第一TCP连接和第二TCP连接所使用的端口号不同,已进行区分。第一终端通过第一TCP连接向第二终端发送文件预览请求;以及通过第一TCP连接接收第二终端发送的文件预览数据;通过第一TCP连接向第二终端发送文件传输请求。通过第二TCP连接接收第二终端发送的至少一个文件数据。也就是说,第一TCP连接用于传输消息,而第二TCP连接用于传输数据。
当然,第一终端和第二终端之间所建立的连接不限于TCP连接,例如在第一终端和第二终端之间建立服务器-客户端连接,同样可以完成图1所示的数据传输方法。其中,作为数据发送端的第二终端作为服务器,作为数据接收端的第一终端作为客户端。
第一终端发送文件预览请求和接收文件预览数据可以采用JavaScript对象表示法(JavaScript Object Notation,JSON)协议,第一终端发送文件传输请求和接收文件数据可以采用任一种适于进行文件传输的协议。但本发明实施例所提供的数据传输方法不对上述协议进行限制,第一终端和第二终端之间还可以采用任一种其他传输协议进行数据传输。
由于终端设备中所存储的文件众多,第一终端一般不会请求第二终端发送第二终端所存储的所有文件的文件预览数据。因此,第一终端发送的文件预览请求可以对所需获取的文件预览数据的属性进行限定。例如第一终端发送的文件预览请求中包括请求预览的文件类型,这里的文件类型可以是图片、视频、文档中的任一种或多种。那么当第二终端接收到文件预览请求之后,将对所存储的文件进行筛选,仅向第一终端发送相应类型的文件预览数据。或者第一终端发送的文件预览请求中包括请求预览的文件的修改时间、大小等其他属性,第二终端在接收到文件预览请求之后将筛选出适合的文件,并向第一终端发送相应的文件预览数据。
第二终端向第一终端发送的文件预览数据也可以为多种形式,例如为预览的文件数据的文件名称、缩略图等。以文件预览数据为预览的文件数据(以下简称预览文件)的缩略图为例,第一终端向第二终端发送的文件预览请求中可以包括请求预览文件的类型和预览文件缩略图的尺寸,例如请求预览文件的类型为图片,缩略图尺寸为80×80像素,或者请求预览文件的类型为视频,缩略图尺寸为100×100像素等。这样当第二终端接收到文件预览请求后,将筛选出相应类型的文件数据,并将文件数据编码为相应尺寸的缩略图。若请求预览文件的类型为图片,则预览文件的缩略图就是将相应的图片文件压缩为缩略图尺寸规定的大小,但缩略图中的图像与原始图片文件相同。若请求预览文件的类型为视频,则预览文件的缩略图可以是将视频文件的任一帧图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图,一般地,可以将视频文件的第一帧图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图。若请求预览文件的类型为文档,则预览文件的缩略图可以是将文档的任一页图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图,一般地,可以将文档的第一页图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图。第一终端即可接收到多个文件预览数据,其中每个文件预览数据包括预览文件的名称、文件类型、文件大小和缩略图编码数据。第一终端对接收到的缩略图编码数据进行解码后即可获得相应的缩略图。
需要说明的是,第一终端在接收到第二终端发送的至少一个文件预览数据之后,为了使用户直观地获知第二终端中存储的文件,并便于对文件进行选择,第一终端还可以在显示屏上显示获取到的至少一个文件预览数据。用户可以在第一终端的显示屏上对多个文件预览数据进行浏览,选择所需获取的文件预览数据,从而生成文件传输指示。以文件预览数据为预览文件的缩略图为例,当第一终端接收到多个预览文件的缩略图后,可以 在显示屏上顺序排列多个缩略图,用户可以直观地看到第二终端存储的多个文件。若第一终端的显示屏为触控屏幕,则用户可以通过触控屏幕选择所需获的文件对应的缩略图。当然,若第一终端的显示屏不是触控屏幕,用户也可以通过第一终端的控制按键选择索取获取的文件对应的缩略图。或者用户也可以通过语音输入、手势输入等方式选择相应的缩略图。
本发明实施例还记载了第一种计算机存储介质,所述第一种计算机存储介质中存储有计算机程序,所述计算机程序用于执行本发明实施例中图1所示的数据传输方法。
图2为本发明实施例提供的数据传输方法实施例二的流程图,如图2所示,本实施例提供的数据传输方法包括:
步骤S201,第二终端接收第一终端发送的文件预览请求,文件预览请求用于请求预览第二终端存储的至少一个文件数据。
步骤S202,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小。
步骤S203,第二终端接收第一终端发送文件传输请求,文件传输请求用于请求第二终端传输至少一个文件数据;具体地,所述第二终端接收所述第一终端发送文件传输请求;所述文件传输请求是所述第一终端基于文件传输指示而生成的;所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据。
步骤S204,第二终端向第一终端发送所述至少一个文件数据,具体地,所述第二终端基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
本实施例提供的数据传输方法以作为文件数据发送方的第二终端为执行主体,但第二终端所执行的处理已在图1所示实施例中进行了详细说明, 此处不在赘述。
同样地,若第二终端和第一终端之间是通过TCP连接进行数据传输,那么第二终端在接收第一终端发送的文件预览请求之前,还需要接收第一终端发送的UDP广播消息,从而在第二终端和第一终端之间建立TCP连接。第二终端和第一终端之间建立TCP连接的过程和方法已在前述实施例中进行了详细说明,此处不再赘述。
需要说明的是,当第二终端接收到第一终端发送的文件预览请求后,还需要根据文件预览请求中所指示的信息,生成至少一个文件预览数据。第二终端接收到的文件预览请求可以对所需获取的文件预览数据的属性进行限定。例如文件预览请求中包括请求预览的文件类型,这里的文件类型可以是图片、视频、文档中的任一种或多种。那么当第二终端接收到文件预览请求之后,将对所存储的文件进行筛选,仅生成相应类型的文件预览数据。或者文件预览请求中包括请求预览的文件的修改时间、大小等其他属性,第二终端在接收到文件预览请求之后将筛选出适合的文件,仅生成相应的文件预览数据。第二终端生成的文件预览数据可以为多种形式,例如为预览文件的文件名称、缩略图等。以文件预览数据为预览文件的缩略图为例,第一终端向第二终端发送的文件预览请求中可以包括请求预览文件的类型和预览文件缩略图的尺寸,例如请求预览文件的类型为图片,缩略图尺寸为80×80像素,或者请求预览文件的类型为视频,缩略图尺寸为100×100像素等。这样当第二终端接收到文件预览请求后,将筛选出相应类型的文件数据,并将文件数据编码为相应尺寸的缩略图。若请求预览文件的类型为图片,则预览文件的缩略图就是将相应的图片文件压缩为缩略图尺寸规定的大小,但缩略图中的图像与原始图片文件相同。若请求预览文件的类型为视频,则预览文件的缩略图可以是将视频文件的任一帧图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图,一般地,可以将视 频文件的第一帧图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图。若请求预览文件的类型为文档,则预览文件的缩略图可以是将文档的任一页图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图,一般地,可以将文档的第一页图像压缩为缩略图尺寸规定的大小作为预览文件的缩略图。第一终端即可接收到多个文件预览数据,其中每个文件预览数据包括预览文件的名称、文件类型、文件大小和缩略图编码数据。第一终端对接收到的缩略图编码数据进行解码后即可获得相应的缩略图。
本发明实施例还记载了第二种计算机存储介质,所述第二种计算机存储介质中存储有计算机程序,所述计算机程序用于执行本发明实施例中图2所示的数据传输方法。
以上各实施例对本发明实施例提供的数据传输方法的方法流程进行了说明,下面以一个具体实施例对本发明实施例提供的数据传输方法进行进一步说明。
图3为本发明实施例提供的数据传输方法实施例三的流程图,如图3所示,本实施例提供的数据传输方法包括:
步骤S301,第一终端和第二终端之间建立TCP连接。
具体地,本实施例以第一终端和第二终端在同一局域网中建立TCP连接为例。首先第一终端和第二终端之间需要进行UDP广播,通过相互广播的UDP报文发现对方。然后进行TCP连接的建立,这里的TCP连接可以为TCP套接字连接。并且为了便于文件预览数据和文件数据的传输,可以同时建立两个TCP连接,其中第一TCP连接用于传输文件预览请求、文件预览数据和文件传输请求,第一TCP连接可以采用JSON协议格式。第二TCP连接用于传输文件数据。第一TCP连接和第二TCP连接使用不同的端口号。
步骤S302,第一终端使用第一TCP连接向第二终端发送缩略图发送请 求。
具体地,在本实施例中,以文件预览数据为预览文件的缩略图为例,那么第一终端向第二终端发送的文件预览请求实际为缩略图发送请求。缩略图发送请求可以采用JSON协议格式,其中包括请求预览的文件类型和缩略图大小。
文件预览请求例如可以为:{“MSGType”:“1”,“FileType”:“Video”,“Size”:“80x80”}。其中“MSGType”表示信息类型,其值为“1”表示这个信息是文件预览请求。“FileType”表示文件类型,其值“Video”表示文件类型为视频。“Size”表示文件大小,其值“80x80”表示缩略图大小为80x80像素。
步骤S303,第二终端生成缩略图预览数据。
具体地,第二终端接收到第一终端发送的缩略图发送请求后,对其进行解析,获知第一终端所需的缩略图文件类型、大小等信息。然后通过系统应用程序编码接口(Application Programming Interface,API)获取相应文件数据的缩略图。对获取到的缩略图进行编码获得缩略图编码数据,这里的编码可以采用任一种编码方式,例如Bsse64编码方式。最后将缩略图文件编码数据、文件名称、文件大小等信息转换为JSON协议格式,生成缩略图预览数据。
第二终端生成的文件预览数据例如可以为:{“MSGType”:“2”,“FileList”:[{“FileName”:“video1.mp4”,“FileIndex”:“1”,“FileType”:“Video”,“FileSize”:“24258654”,“ThumbnailData”:“缩略图Base64编码数据”},{“FileName”:“video2.mp4”,“FileIndex”:“2”,“FileType”:“Video”“FileSize”:“247585684”,“ThumbnailData”:“缩略图Base64编码数据”}…]}。其中“MSGType”表示信息类型,其值为“2”表示这个信息是文件预览数据。“FileList”表示文件列表,由于第一终端发送的文件预览请求中请求的是一个类型的文件预览数据,而第二终端中可能具有多个相应的类型的文件数据,因此第二终端生成的文件预览数据中将包括多个文件 数据对应的文件预览数据。“FileName”表示文件名称,其值“video1.mp4”、“video2.mp4”表示文件数据的名称。“FileIndex”表示文件索引,其值“1”、“2”表示文件预览数据在列表中的排序。“FileType”表示文件类型,其值“Video”表示文件类型为视频。“FileSize”表示文件的大小,其值“24258654”、“247585684”表示文件数据所占用的字节数。“ThumbnailData”表示缩略图文件数据,其值“缩略图Base64编码数据”中填充缩略图文件编码后的数据。
步骤S304,第二终端向第一终端发送缩略图预览数据。
具体地,第二终端通过第一TCP连接向第一终端发送缩略图预览数据。
步骤S305,第一终端解码缩略图预览数据,并向用户显示缩略图预览数据。
具体地,第一终端将缩略图预览数据进行解码后,获取到各文件数据对的缩略图,并在显示屏上向用户进行显示。用户可以获知缩略图来自第二终端。
步骤S306,第一终端获取用户输入的文件传输指示。
具体地,用户可以在第一终端的显示屏上通过拖曳、点击等方式选择所需获取的文件数据对应的缩略图。当然,用户也可以通过语音输入、手势输入等方式选择相应的缩略图。用户选择的缩略图即为用户输入的文件传输指示,该文件传输指示用户指示第一终端获取用户选择的缩略图对应的文件数据。
步骤S307,第一终端向第二终端发送文件传输请求。
具体地,第一终端通过第一TCP连接向第二终端发送文件传输请求,文件传输请求可以采用JSON协议格式。
文件传输请求例如可以为:{“MSGType”:“3”,“FileList”:[{“FileName”:“video1.mp4”,“FileIndex”:“1”,“FileType”:“Video”“FileSize”:“24258654”}]}。其中“MSGType”表示信息类型,其值为“3”表示这个信息是文件传输请求。“FileList”表示文件列表,用户可能需要获取第二终 端中存储的多个文件数据,因此文件传输请求中可能包括多个文件数据的传输请求,以文件列表方式表示。“FileName”表示文件名称,其值“video1.mp4”表示文件数据的名称。“FileIndex”表示文件索引,其值“1”表示文件预览数据在列表中的排序。“FileType”表示文件类型,其值“Video”表示文件类型为视频。“FileSize”表示文件的大小,其值“24258654”表示文件数据所占用的字节数。
步骤S308,第二终端向第一终端发送文件数据。
具体地,第二终端在接收到文件传输请求后,确定第一终端需要获取的文件数据,并将其通过第二TCP连接发送至第一终端。
第二终端可以通过以下协议格式向第一终端发送文件数据:<HeadFlag><NameLength><Name><Filesize><Stream>。其中<HeadFlag>为数据包头,占用4字节,其值为0xFFFFFFFF表示数据包头。<NameLength>为1字节,为文件字符名长度。<Name>为N字节文件名。<Filesize>为8字节,表示文件数据大小。<Stream>为文件数据流。
图4为本发明实施例提供的数据传输装置实施例一的结构示意图,如图4所示,本实施例提供的数据传输装置包括:
第一发送模块41,配置为向第二终端发送文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据。
第一接收模块42,配置为接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小。
获取模块43,配置为获取用户输入的文件传输指示,所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据。
第一发送模块41,还配置为向所述第二终端发送基于所述文件传输指 示而生成的文件传输请求。
第一接收模块42,还配置为接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
本实施例提供的数据传输装置用户实现图1所示的数据传输方法的处理,其实现原理和技术效果类似,此处不再赘述。
图5为本发明实施例提供的数据传输装置实施例二的结构示意图,如图5所示,本实施例提供的数据传输装置在图4的基础上,还包括:第一连接建立模块51。
第一接收模块42,还配置为接收所述第二终端发送的UDP广播消息。
第一连接建立模块51,配置为与所述第二终端建立第一TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同。
第一发送模块41,还配置为通过所述第一TCP连接向所述第二终端发送所述文件预览请求;通过所述第一TCP连接向所述第二终端发送基于所述文件传输指示而生成的所述文件传输请求。
第一接收模块42,还配置为通通过所述第一TCP连接接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据;通过所述第二TCP连接接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
进一步地,在图4或图5所示实施例中,所述文件预览数据至少包括预览的文件数据的缩略图;所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸,所述文件类型包括图片、视频、文档中的至少一种;第一接收模块42,还配置为接收所述第二终端基于所述文件预览请求而发送的至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
图6为本发明实施例提供的数据传输装置实施例三的结构示意图,如 图6所示,本实施例提供的数据传输装置在图5的基础上,还包括:显示模块61,配置为向用户显示所述至少一个文件预览数据。
获取模块43,还配置为获取用户从所述至少一个文件预览数据中选择的文件预览数据,基于用户选择的至少一个文件预览数据生成所述文件传输指示,所述文件传输指示用于指示传输用户选择的至少一个文件预览数据所对应的文件数据。
图7为本发明实施例提供的数据传输装置实施例四的结构示意图,如图7所示,本实施例提供的数据传输装置,包括:
第二接收模块71,配置为接收第一终端发送的文件预览请求,所述文件预览请求用于请求预览所述数据传输装置存储的至少一个文件数据。
第二发送模块72,配置为基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小。
第二接收模块71,还配置为接收所述第一终端发送文件传输请求;所述文件传输请求是所述第一终端基于文件传输指示而生成的;所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据。
第二发送模块72,还配置为配置为基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
本实施例提供的数据传输装置用户实现图2所示的数据传输方法的处理,其实现原理和技术效果类似,此处不再赘述。
图8为本发明实施例提供的数据传输装置实施例五的结构示意图,如图8所示,本实施例提供的数据传输装置在图7的基础上,还包括:第二连接建立模块81。
第二接收模块71,还配置为接收所述第一终端发送的UDP广播消息。
第二连接建立模块81,配置为与所述第一终端建立第一TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同。
第二接收模块71,还配置为通过所述第一TCP连接接收第一终端发送的文件预览请求;通过所述第一TCP连接接收所述第一终端发送文件传输请求。
第二发送模块72,还配置为基于所述文件预览请求并通过所述第一TCP连接向所述第一终端发送至少一个文件预览数据;基于所述文件传输请求并通过所述第二TCP连接向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
图9为本发明实施例提供的数据传输装置实施例六的结构示意图,如图9所示,本实施例提供的数据传输装置在图8的基础上,还包括:生成模块91,配置为根据所述文件预览请求生成表征至少一个文件数据的至少一个文件预览数据。
进一步地,在图7至图9所示实施例中,所述文件预览数据至少包括预览的文件数据的缩略图。所述文件预览请求包括请求预览的文件数据的文件类型和预览文件缩略图尺寸,所述文件类型包括图片、视频、文档中的至少一种。第二发送模块72,还配置为基于所述文件预览请求向所述第一终端发送至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
本发明上述各实施例中,第一发送模块41和第二发送模块72可以通过发送器或收发器实现;第一接收模块42和第二接收模块71可以对应通过接收器或收发器实现;获取模块43、第一连接建立模块51、第二连接建立模块81、生成模块91可以由中央处理器(Central Processing Unit,CPU)、微处理器(Micro Processor Unit,MPU)、数字信号处理器(Digital Signal Processor,DSP)或现场可编程门阵列(Field Programmable Gate Array, FPGA)等实现。显示模块61可以由显示器实现。
本发明实施例还提供一种终端设备,需要说明的是,本发明上述各实施例中,第一发送模块41和第二发送模块72可以为终端设备中的发送器或收发器;第一接收模块42和第二接收模块71可以为终端设备中的接收器或收发器。获取模块43、第一连接建立模块51、第二连接建立模块81、生成模块91可以由终端设备的CPU、MPU、DSP或FPGA等实现。显示模块61可以由终端设备的显示器实现。终端设备还包括存储器,配置为存储程序代码,处理器调用存储器中存储的程序代码,以实现本发明实施例提供的数据传输方法。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个 流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。
工业实用性
本发明实施例通过第一终端通过向第二终端发送文件预览请求,接收第二终端发送的文件预览数据,使第一终端能够根据文件预览数据选择所需获取的文件数据,并从第二终端获取用户选择的文件数据,使文件接收方能够主动获取文件,提高了用户体验。

Claims (18)

  1. 一种数据传输方法,所述方法包括:
    第一终端向第二终端发送文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据;
    所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
    所述第一终端获取文件传输指示,所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
    所述第一终端向所述第二终端发送基于所述文件传输指示而生成的文件传输请求;
    所述第一终端接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
  2. 根据权利要求1所述的方法,其中,所述第一终端向第二终端发送文件预览请求之前,所述方法还包括:
    所述第一终端接收所述第二终端发送的用户数据报文协议UDP广播消息;
    所述第一终端与所述第二终端建立第一传输控制协议TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
    对应地,所述第一终端向第二终端发送文件预览请求,包括:
    所述第一终端通过所述第一TCP连接向所述第二终端发送所述文件预览请求;
    对应地,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,包括:
    所述第一终端通过所述第一TCP连接接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据;
    对应地,所述第一终端向所述第二终端发送基于所述文件传输指示而生成的文件传输请求,包括:
    所述第一终端通过所述第一TCP连接向所述第二终端发送基于所述文件传输指示而生成的所述文件传输请求;
    对应地,所述第一终端接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据,包括:
    所述第一终端通过所述第二TCP连接接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
  3. 根据权利要求1或2所述的方法,其中,所述文件预览数据至少包括预览的文件数据的缩略图;
    所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸;
    对应地,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据,包括:
    所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
  4. 根据权利要求1或2所述的方法,其中,所述第一终端接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据之后,所述方法还包括:
    所述第一终端向用户显示所述至少一个文件预览数据;
    对应地,所述第一终端获取文件传输指示,包括:
    所述第一终端获取用户从所述至少一个文件预览数据中选择的文件预览数据,基于用户选择的至少一个文件预览数据生成所述文件传输指示, 所述文件传输指示用于指示传输用户选择的至少一个文件预览数据所对应的文件数据。
  5. 一种数据传输方法,所述方法包括:
    第二终端接收第一终端发送的文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据;
    所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
    所述第二终端接收所述第一终端发送文件传输请求;所述文件传输请求是所述第一终端基于文件传输指示而生成的;所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
    所述第二终端基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
  6. 根据权利要求5所示的方法,其中,所述第二终端接收第一终端发送的文件预览请求之前,所述方法还包括:
    所述第二终端接收所述第一终端发送的用户数据报文协议UDP广播消息;
    所述第二终端与所述第一终端建立第一传输控制协议TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
    对应地,所述第二终端接收第一终端发送的文件预览请求,包括:
    所述第二终端通过所述第一TCP连接接收第一终端发送的文件预览请求;
    对应地,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,包括:
    所述第二终端基于所述文件预览请求并通过所述第一TCP连接向所述 第一终端发送至少一个文件预览数据;
    对应地所述第二终端接收所述第一终端发送文件传输请求,包括:
    所述第二终端通过所述第一TCP连接接收所述第一终端发送文件传输请求;
    对应地,所述第二终端基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据,包括:
    所述第二终端基于所述文件传输请求并通过所述第二TCP连接向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
  7. 根据权利要求5或6所述的方法,其中,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据之前,所述方法还包括:
    所述第二终端根据所述文件预览请求生成表征至少一个文件数据的至少一个文件预览数据。
  8. 根据权利要求5或6所述的方法,其中,所述文件预览数据至少包括预览的文件数据的缩略图;
    所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸;
    对应地,所述第二终端基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,包括:
    所述第二终端基于所述文件预览请求向所述第一终端发送至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
  9. 一种数据传输装置,所述装置包括:
    第一发送模块,配置为向第二终端发送文件预览请求,所述文件预览请求用于请求预览所述第二终端存储的至少一个文件数据;
    第一接收模块,配置为接收所述第二终端基于所述文件预览请求而发 送的至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
    获取模块,配置为获取用户输入的文件传输指示,所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
    所述第一发送模块,还配置为向所述第二终端发送基于所述文件传输指示而生成的文件传输请求;
    所述第一接收模块,还配置为接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
  10. 根据权利要求9所述的装置,其中,所述第一接收模块,还配置为接收所述第二终端发送的用户数据报文协议UDP广播消息;
    所述装置还包括:第一连接建立模块,配置为与所述第二终端建立第一传输控制协议TCP连接和第二TCP连接,所述第一TCP连接和所述第二TCP连接的端口号不同;
    对应地,所述第一发送模块,还配置为通过所述第一TCP连接向所述第二终端发送所述文件预览请求;通过所述第一TCP连接向所述第二终端发送基于所述文件传输指示而生成的所述文件传输请求;
    所述第一接收模块,还配置为通过所述第一TCP连接接收所述第二终端基于所述文件预览请求而发送的至少一个文件预览数据;通过所述第二TCP连接接收所述第二终端基于所述文件传输请求而发送的所述文件传输指示所指示的所述至少一个文件数据。
  11. 根据权利要求9或10所述的装置,其中,所述文件预览数据至少包括预览的文件数据的缩略图;
    所述文件预览请求包括请求预览的文件数据的文件类型和缩略图尺寸;
    对应地,所述第一接收模块,还配置为接收所述第二终端基于所述文件预览请求而发送的至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
  12. 根据权利要求9或10所述的装置,其中,所述装置还包括:显示模块,配置为向用户显示所述至少一个文件预览数据;
    所述获取模块,还配置为获取用户从所述至少一个文件预览数据中选择的文件预览数据,基于用户选择的至少一个文件预览数据生成所述文件传输指示,所述文件传输指示用于指示传输用户选择的至少一个文件预览数据所对应的文件数据。
  13. 一种数据传输装置,所述装置包括:
    第二接收模块,配置为接收第一终端发送的文件预览请求,所述文件预览请求用于请求预览所述数据传输装置存储的至少一个文件数据;
    第二发送模块,配置为基于所述文件预览请求向所述第一终端发送至少一个文件预览数据,所述文件预览数据能够表征文件数据,每个文件预览数据的大小小于对应的文件数据的大小;
    所述第二接收模块,还配置为接收所述第一终端发送文件传输请求;所述文件传输请求是所述第一终端基于文件传输指示而生成的;所述文件传输指示用于指示传输选自所述至少一个文件预览数据所表征的至少一个文件数据;
    所述第二发送模块,还配置为基于所述文件传输请求向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
  14. 根据权利要求13所示的装置,其中,所述第二接收模块,还配置为接收所述第一终端发送的用户数据报文协议UDP广播消息;
    所述装置还包括:第二连接建立模块,配置为与所述第一终端建立第一传输控制协议TCP连接和第二TCP连接,所述第一TCP连接和所述第 二TCP连接的端口号不同;
    对应地,所述第二接收模块,还配置为通过所述第一TCP连接接收第一终端发送的文件预览请求;通过所述第一TCP连接接收所述第一终端发送文件传输请求;
    所述第二发送模块,还配置为基于所述文件预览请求并通过所述第一TCP连接向所述第一终端发送至少一个文件预览数据;基于所述文件传输请求并通过所述第二TCP连接向所述第一终端发送所述文件传输指示所指示的至少一个文件数据。
  15. 根据权利要求13或14所述的装置,其中,所述装置还包括:生成模块,配置为根据所述文件预览请求生成表征至少一个文件数据的至少一个文件预览数据。
  16. 根据权利要求13或14所述的装置,其中,所述文件预览数据至少包括预览的文件数据的缩略图;
    所述文件预览请求包括请求预览的文件数据的文件类型和预览文件缩略图尺寸;
    所述第二发送模块,还配置为基于所述文件预览请求向所述第一终端发送至少一个预览的文件数据的文件名称、文件类型、文件大小和缩略图编码数据。
  17. 第一种计算机存储介质,所述计算机存储介质中存储有计算机程序,所述计算机程序用于执行前述权利要求1至4任一项所述的数据传输方法。
  18. 第二种计算机存储介质,所述计算机存储介质中存储有计算机程序,所述计算机程序用于执行前述权利要求5至8任一项所述的数据传输方法。
PCT/CN2017/081964 2016-07-15 2017-04-26 一种数据传输方法及装置、存储介质 WO2018010469A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610556382.5 2016-07-15
CN201610556382.5A CN107634974A (zh) 2016-07-15 2016-07-15 一种数据传输方法及装置

Publications (1)

Publication Number Publication Date
WO2018010469A1 true WO2018010469A1 (zh) 2018-01-18

Family

ID=60951908

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/081964 WO2018010469A1 (zh) 2016-07-15 2017-04-26 一种数据传输方法及装置、存储介质

Country Status (2)

Country Link
CN (1) CN107634974A (zh)
WO (1) WO2018010469A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112055078A (zh) * 2020-09-02 2020-12-08 数字广东网络建设有限公司 一种数据传输方法、装置、计算机设备和存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109558551A (zh) * 2018-10-26 2019-04-02 东软集团股份有限公司 文件预览的方法、装置、存储介质和电子设备
CN112769848B (zh) 2021-01-18 2022-12-20 中国民航信息网络股份有限公司 一种报文发送方法及装置
CN115550405B (zh) * 2022-11-03 2025-04-11 杭州视洞科技有限公司 一种利用客户端获取云服务端视频缩略图的方法及系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050094672A1 (en) * 2003-10-30 2005-05-05 Curitel Communications, Inc. Mobile communication terminal, wireless communication system and method of previewing a moving image
CN103634362A (zh) * 2012-08-28 2014-03-12 金蝶软件(中国)有限公司 文件传送方法、文件服务器及文件传送系统
CN104573090A (zh) * 2015-01-29 2015-04-29 深圳市中兴移动通信有限公司 一种文件分享方法、装置及终端

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9767845B2 (en) * 2013-02-05 2017-09-19 Alc Holdings, Inc. Activating a video based on location in screen
CN105451161B (zh) * 2015-11-06 2019-09-13 上海斐讯数据通信技术有限公司 基于安卓手机内置基站方式实现文件共享方法及系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050094672A1 (en) * 2003-10-30 2005-05-05 Curitel Communications, Inc. Mobile communication terminal, wireless communication system and method of previewing a moving image
CN103634362A (zh) * 2012-08-28 2014-03-12 金蝶软件(中国)有限公司 文件传送方法、文件服务器及文件传送系统
CN104573090A (zh) * 2015-01-29 2015-04-29 深圳市中兴移动通信有限公司 一种文件分享方法、装置及终端

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112055078A (zh) * 2020-09-02 2020-12-08 数字广东网络建设有限公司 一种数据传输方法、装置、计算机设备和存储介质
CN112055078B (zh) * 2020-09-02 2023-10-03 数字广东网络建设有限公司 一种数据传输方法、装置、计算机设备和存储介质

Also Published As

Publication number Publication date
CN107634974A (zh) 2018-01-26

Similar Documents

Publication Publication Date Title
JP6275201B2 (ja) 文字送信方法、コンピュータプログラム、および、文字送信システム
WO2018010469A1 (zh) 一种数据传输方法及装置、存储介质
EP2933982A1 (en) Media stream transfer method and user equipment
CN104321760A (zh) 一种通过互联网将文件公开及共享的系统和方法
TW201244432A (en) Graphics sharing method, system and terminal
CN103648015A (zh) 一种数据显示方法和设备
WO2013167081A2 (zh) 一种实现多屏显示的方法及系统
WO2017028655A1 (zh) 一种截屏方法、终端及机顶盒
CN107786415B (zh) 一种业务处理方法及相关设备与系统
WO2015176648A1 (zh) 将智能终端上的数据传输至电视终端的方法、装置
CN107908337A (zh) 分享图像内容的方法和装置
CN104601715A (zh) 一种基于二维码的文件共享方法、系统及移动终端
CN104484144A (zh) 图片传输方法及装置
CN106470222A (zh) 一种文件传输方法、装置及应用服务器
CN102308558B (zh) 显示图片的方法、装置和系统
CN103945165A (zh) 终端设备远程视频传输的处理方法和装置
WO2014056427A1 (zh) 展示多幅图像的方法、装置、家庭网络系统和移动终端
CN103412728B (zh) 基于局域网的设备文件打印的方法和系统
CN111404977B (zh) 文档远程演示和观看方法以及终端设备
CN103747058B (zh) 一种展示图片的方法和装置
CN104079953B (zh) 基于视频信息分享操作的方法和系统
JP2010056966A (ja) 画像コンテンツ送信サーバ、画像表示装置、画像コンテンツ送信方法、及び、画像表示方法
WO2016177257A1 (zh) 一种数据分享的方法和装置
CN104580289A (zh) 一种对用户设备进行控制的方法、装置和系统
CN115086295A (zh) 文件传输方法、文件传输装置、服务器及存储介质

Legal Events

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

Ref document number: 17826808

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17826808

Country of ref document: EP

Kind code of ref document: A1