Disclosure of Invention
In order to solve the existing technical problem, embodiments of the present invention provide a method and an apparatus for uploading a file by a mobile terminal, which can simplify the operation of uploading a file by the mobile terminal and avoid a cumbersome file searching process.
In order to achieve the above purpose, the technical solution of the embodiment of the present invention is realized as follows:
the embodiment of the invention provides a method for uploading files by a mobile terminal, which comprises the following steps:
determining a file to be uploaded, and setting a mark to be uploaded for the determined file to be uploaded;
and selecting the uploaded files from the files with the marks to be uploaded, and sending the selected uploaded files to the computer equipment.
In the above scheme, the method further comprises: adding a database column for recording whether the file is to be uploaded or not in a media database of the mobile terminal;
the setting of the to-be-uploaded mark for the determined file to be uploaded comprises the following steps: and updating the content information corresponding to the database column.
In the above scheme, after the mark to be uploaded is set for the determined file to be uploaded, the method further includes: and storing the file with the mark to be uploaded and the corresponding file address in a specified directory of the mobile terminal in a form of a file list to be uploaded.
In the above scheme, before selecting the uploaded file, the method further includes: and uploading the file list to be uploaded in the appointed directory so as to select the uploaded files.
The embodiment of the invention also provides a device for uploading files by the mobile terminal, which comprises: the system comprises a marking module, a selecting module and an uploading module; wherein,
the marking module is used for determining the files to be uploaded and setting marks to be uploaded for the determined files to be uploaded;
the selection module is used for selecting the uploaded files from the files with the marks to be uploaded;
and the uploading module is used for sending the selected uploaded file to the computer equipment.
In the above scheme, the apparatus further comprises: the mobile terminal comprises a setting module, a database processing module and a file uploading module, wherein the setting module is used for adding a database column for recording whether a file to be uploaded is in a media database of the mobile terminal; the marking module is specifically configured to update the content information corresponding to the database column.
In the above scheme, the apparatus further comprises: and the storage module is used for storing the file with the mark to be uploaded and the corresponding file address in a specified directory of the mobile terminal in a form of a file list to be uploaded.
In the above scheme, the uploading module is further configured to upload the list of files to be uploaded in the specified directory, so as to select files to be uploaded.
The method and the device for uploading the files by the mobile terminal provided by the embodiment of the invention firstly determine the files to be uploaded, and set the marks to be uploaded for the determined files to be uploaded; and then selecting the uploaded files from the files with the marks to be uploaded, and sending the selected uploaded files to the computer equipment. Therefore, as the special mark is set for the file to be uploaded, the range of selecting the file to be uploaded can be narrowed, and the file searching time is shortened; moreover, the selected uploading files are directly sent to the computer equipment side by the mobile terminal side, and the complex process that the mobile terminal needs to be connected first and then the files needing to be uploaded are searched one by one in the prior art is avoided, so that the operation of uploading the files by the mobile terminal is simplified, the speed of uploading the files is increased, and the user experience is improved.
Detailed Description
Fig. 1 is a schematic view of an implementation flow of a method for uploading a file by a mobile terminal according to an embodiment of the present invention, and as shown in fig. 1, the method for uploading a file by a mobile terminal according to an embodiment of the present invention includes the following steps: .
Step 101, determining a file to be uploaded, and setting a mark to be uploaded for the determined file to be uploaded;
generally, a media database is provided in the mobile terminal for recording necessary information corresponding to each media file in the mobile terminal; each record in the media database corresponds to a media file, and comprises all necessary information to be recorded of the media file.
Specifically, the necessary information recorded for each media file in the mobile terminal in the native media database is shown in table 1, table 2, and table 3, where table 1, table 2, and table 3 are respectively information lists of general files for recording three types of media files, i.e., video, music, and picture, in the media database, and each corresponding media file includes a database column name and corresponding content information.
TABLE 1
| Database column name | Content information |
| _id | Main Key, music ID |
| _data | Music address |
| _display_name | Filename |
| _size | File size |
| mime_type | MIME type |
| date_added | Time of addition to media library |
| date_modified | Most recent storage time |
| title | Title |
| resolution | Resolution ratio |
| bucket_name | Name of folder |
| album | Album name |
| is_record | Whether it is a recording |
TABLE 2
TABLE 3
From the information recorded by three media files of video, music and picture, the information recorded by the media database has many common information, such as: ID. The PC terminal can find the media files in the mobile terminal by acquiring the general information, such as the title, the folder name, the address of the files and the like. However, it is irrelevant whether the media files stored in the mobile terminal need to be uploaded with general information of the database. Therefore, the native media database needs to be upgraded.
Based on this, the embodiment of the invention adds a database column for recording whether the file is to be uploaded or not in the media database of the mobile terminal; correspondingly, the setting of the to-be-uploaded mark for the determined file to be uploaded is to update the content information corresponding to the database column.
As shown in table 4, the "is _ upload" column indicates whether the file is to be uploaded, the updating of the content information of the database column is equivalent to setting a to-be-uploaded flag for the file to be uploaded, and a setting such as setting to 1 may be used to indicate that the file is to be uploaded; otherwise, setting to 0 indicates that the file is not to be uploaded. Table 4 lists only the main content information common to tables 1, 2, and 3 to illustrate the change of the media database record; all original database column names and corresponding content information in the tables 1, 2 and 3 exist and are kept unchanged; in other words, the "is _ upload" column and the corresponding content information are added to the original contents in table 1, table 2, and table 3, respectively.
TABLE 4
In practical application, the "is _ upload" column in table 4 is added to tables 1 to 3 respectively, and corresponds to the recording of three types of media files, i.e. tables 1 to 3 are still true in the mobile terminal, and only updated tables 1 to 3 with the "is _ upload" column are added; specifically, each database table is located under mobile terminal/data/data/com. And adding a column with a database column name of 'is _ upload' to each database table of the media database by modifying the Android frame layer code, wherein content information corresponding to the column indicates whether the file is to be uploaded or not, and modifying the content information of the column is to set a to-be-uploaded mark for the corresponding file.
Since each application, such as a video player, a music player, and a picture browser, needs to be accessed, each will add an "is _ upload" column, and then the Android framework layer will upgrade this accordingly. The method comprises the following steps: and adding a new function getIsUpload, wherein the function interface can obtain the information whether a certain media file user needs to upload or not by using a naming rule for obtaining the file ID and the path and a method for newly creating the function getIsUpload.
Therefore, before step 101, the method further comprises: modifying the Android frame layer code and upgrading the media database; the specific operation is as follows: add getisappload function and add "is _ upload" column in the database table.
After the Android frame layer code is modified and the media database is upgraded, a new media database is generated according to the modification of the Android code, and an added 'is _ upload' column is used for marking a file to be uploaded, namely, the function of marking whether the file is to be uploaded or not by a user is supported, so that the operation of uploading the file after the mobile terminal is connected with a PC (personal computer) end by the user is facilitated.
The setting of the to-be-uploaded mark in step 101 may be implemented by providing an interactive interface for a user, and the specific implementation method may be various, for example: adding an item of 'waiting to upload' in the menu operation for the media file can be determined according to different application interface styles. Here, as an example of an interface model for adding a to-be-uploaded list to a certain mp3 file, as shown in fig. 2, when an item "to-be-uploaded" is selected in the right menu of "example 1.mp 3", the file is added with a to-be-uploaded flag.
Further, storing the file with the mark to be uploaded and the corresponding file address in a specified directory of the mobile terminal in a list form of the file to be uploaded;
specifically, a list file with a certain format may be generated in a specified directory of the mobile terminal, and a file address to be uploaded with a mark is recorded as a file list to be uploaded, as shown in table 5, the file format of the list file needs to be a file that can be identified by the computer device, and which files in the currently connected mobile terminal need to be uploaded can be known through file names.
| Filename | Address |
| example1.mp3 | /sdcard/download/example1.mp3 |
| example2.txt | /data/data/example2.txt |
| example3.ape | /zte_file/example/example3.ape |
| exampe4.mp4 | /tmp/file/exampe4.mp4 |
TABLE 5
102, selecting uploaded files from files with marks to be uploaded, and sending the selected uploaded files to computer equipment;
specifically, when the mobile terminal is connected with the computer device, the computer device sends a request for acquiring device data to the mobile terminal; after the mobile terminal is connected, the mobile terminal and the computer equipment can communicate according to an MTP protocol; here, the user of the MTP includes two parts, an Initiator (Initiator) and a Responder (Responder), as shown in fig. 3. Wherein, initialter refers to USB Host, for example, a PC, a notebook, and other computer devices; the Responder refers to a portable mobile terminal such as a mobile phone and a tablet computer.
When the mobile terminal is connected with the computer equipment, the computer equipment sends a request for acquiring equipment data named GetDeviceInfo; the mobile terminal may listen to the request, and based on the request, the computer device reads the list of files to be uploaded stored in the designated directory of the mobile terminal, locates the file with the flag to be uploaded, and displays a corresponding interface to prompt the user whether to upload the file with the flag to be uploaded, where a similar interface prompt may be as shown in fig. 4. In practical application, the prompt interface can prompt the user at the mobile terminal or can be displayed on the computer device. After the uploading, when the mobile terminal is connected to the computer device next time, the prompt interface still displays all the files with the to-be-uploaded marks set in step 101 for the user to select.
The selected file to be uploaded can be a file with part or all of the marks to be uploaded, and the mobile terminal sends the selected file to the computer equipment to finish the file uploading from the mobile terminal to the computer equipment.
Fig. 5 shows a specific implementation flow of a method for uploading files by a mobile terminal according to an embodiment of the present invention, which is implemented on the premise that a plurality of media files are stored in the mobile terminal, where the media files may be video files, and/or music files, and/or picture files, and recording information corresponding to all the media files is stored in a media database; as shown in fig. 5, the implementation process of the method specifically includes the following steps:
step 1, a user operates a media file existing in a mobile terminal and adds a mark to be uploaded to the file to be uploaded;
here, the user can select whether to add the mark to be uploaded to the media file according to the needs of the user or the needs of the actual application.
Step 2, for the media file added with the mark to be uploaded, setting content information corresponding to the data column in a database column corresponding to the corresponding media file in a media database, and storing the media file added with the mark to be uploaded and the file address thereof under a specified directory of the mobile terminal in a list form;
the embodiment of the invention adds a database column for recording whether the file is to be uploaded or not in a media database of the mobile terminal; correspondingly, the setting of the to-be-uploaded mark for the determined file to be uploaded is to update the content information corresponding to the database column; storing the file with the mark to be uploaded and the corresponding file address in a specified directory of the mobile terminal in a list form of the file to be uploaded;
and directly executing the step 3 for the media file without the mark to be uploaded.
Step 3, updating the media database;
here, the updating means updating the content information corresponding to the database column.
Step 4, the mobile terminal is connected with computer equipment;
specifically, when the mobile terminal is connected with the computer device, the computer device sends a request for acquiring device data to the mobile terminal; after the mobile terminal is connected, the mobile terminal and the computer equipment can communicate according to the MTP protocol.
Step 5, prompting whether the media file added with the mark to be uploaded needs to be uploaded, and sending the file selected to be uploaded to the computer equipment; and for the media files without the marks to be uploaded, uploading the files to the computer equipment by using a common uploading mode.
Specifically, for the media file added with the mark to be uploaded, the computer equipment reads a file list to be uploaded stored in a specified directory of the mobile terminal, positions the file with the mark to be uploaded, and displays a corresponding interface to prompt a user whether the file with the mark to be uploaded needs to be uploaded or not;
the selected file to be uploaded can be a file with a part or all of the file to be uploaded provided with a mark to be uploaded, and the mobile terminal sends the file corresponding to the selected file to the computer equipment to finish the file uploading from the mobile terminal to the computer equipment.
And 6, the computer equipment saves the uploaded files.
An embodiment of the present invention further provides a device for uploading a file by a mobile terminal, where a structure of the device is shown in fig. 6, and the device includes: a marking module 601, a selecting module 602 and an uploading module 603; wherein,
the marking module 601 is configured to determine a file to be uploaded, and set a to-be-uploaded mark for the determined file to be uploaded;
a selecting module 602, configured to select an uploaded file from files with a flag to be uploaded;
and an uploading module 603, configured to send the selected uploaded file to the computer device.
Further, the apparatus further comprises: a setting module 604 and a saving module 605; wherein,
a setting module 604, configured to add a database column for recording whether the file is to be uploaded or not in a media database of the mobile terminal; correspondingly, the marking module 601 is specifically configured to update the content information corresponding to the database column;
the saving module 605 is configured to save the file with the to-be-uploaded flag and the file address corresponding to the file with the to-be-uploaded flag in a specified directory of the mobile terminal in a form of a to-be-uploaded file list.
Further, the uploading module 603 is further configured to upload the list of files to be uploaded in the specified directory, so as to select an uploaded file.
In practical applications, the marking module 601, the selecting module 602, the uploading module 603, and the setting module 604 may be implemented by a Central Processing Unit (CPU), a MicroProcessor Unit (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like on the mobile terminal; the saving module 605 may be implemented by various storage devices located on the mobile terminal.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.