File sharing method and terminal device

By creating metadata for mapped files and generating file descriptor associations in a distributed file system, the problem of different terminal devices being unable to directly access local files is solved, enabling cross-device file sharing and access.

CN113672576BActive Publication Date: 2025-10-24HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202011565581.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2020-05-15
Filing Date
2020-12-25
Publication Date
2025-10-24
Estimated Expiration
2040-12-25

AI Technical Summary

Technical Problem

Because different terminal devices have their own system kernels and memory, applications deployed on one terminal device cannot directly access local files stored on another terminal device.

Method used

By creating metadata of the target file's mapping file in the distributed file system and generating the association between file descriptors and index identifiers, cross-device file access is achieved.

Benefits of technology

It enables direct file access across devices, allowing a second application to access target files on a first terminal device via mapped files or temporary files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113672576B_ABST
    Figure CN113672576B_ABST
Patent Text Reader

Abstract

The application provides a file sharing method and device. A first terminal device opens a target file to be shared, creates a file identifier and an index identifier of a mapping file in a distributed file system, generates a first file descriptor for accessing the target file in an open state and associated with the index identifier for a first distributed file service in the first terminal device, and sends file sharing information containing the file identifier to a second terminal device. The second terminal device opens the mapping file according to the file identifier in the file sharing information, generates a second file descriptor for accessing the mapping file in an open state for a second application in the second terminal device. The second application requests to access the mapping file according to the second file descriptor, so that the second distributed file service in the second terminal device sends a file access request containing the index identifier, and the first distributed file service accesses the target file according to the first file descriptor associated with the index identifier.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of terminal, and in particular, to a file sharing method and a terminal device. BACKGROUND

[0002] Before an application (APP) deployed in a terminal device accesses a local file stored in the terminal device, the application can request a system kernel of the terminal device to open the local file, and obtain a file descriptor (FD) returned by the system kernel to the application. In addition, the system kernel can create a file structure body of the local file, and maintain a mapping relationship between the file descriptor and the file structure body in a file descriptor table corresponding to the application; wherein the file structure body of the local file can represent the local file in an open state. In the process of the application accessing the local file, such as the process of reading / writing the local file, the application can provide a corresponding file descriptor to the system kernel; the system kernel can find a corresponding file structure body according to the file descriptor and the file descriptor table corresponding to the application, that is, find the local file in the open state, and then perform an access operation on the corresponding local file according to the found file structure body, to complete the access of the local file by the application.

[0003] Since different terminal devices each have its own system kernel and memory, an application deployed in one terminal device cannot directly access a local file stored in another terminal device. SUMMARY

[0004] In embodiments of the present application, a file sharing method and a terminal device are provided, and a second application can access a target file shared by a first application, wherein the first application is deployed in a first terminal device, the second application is deployed in a second terminal device, and the target file is a local file stored in the first terminal device.

[0005] In a first aspect, a file sharing method is provided in the embodiments of the present application, and is applied to a first terminal device, wherein the first terminal device is deployed with a first distributed file service. The method comprises the following steps: first, opening a target file, wherein the target file is a local file stored in the first terminal device and to be shared to a second terminal device, and the first terminal device and the second terminal device belong to a same distributed file system; then, creating metadata of a mapping file corresponding to the target file in the distributed file system, wherein the metadata of the mapping file comprises a file identifier of the mapping file and an index identifier; then, generating, for the first distributed file service, a first file descriptor used for accessing the target file in the opened state, and establishing an association relationship between the first file descriptor and the index identifier; and then, sending, to the second terminal device, file sharing information comprising the file identifier.

[0006] In a second aspect, a file sharing method corresponding to the first aspect is provided in the embodiments of the present application, and is applied to a second terminal device, wherein the second terminal device is deployed with a second distributed file service. The method comprises the following steps: receiving file sharing information from a first terminal device, wherein the first terminal device and the second terminal device belong to a same distributed file system, and the file sharing information comprises a file identifier of a mapping file corresponding to a target file in the distributed file system, and the target file is a local file stored in the first terminal device and to be shared to the second terminal device; then, opening the mapping file according to the file identifier; then, generating, for a second application program, a second file descriptor used for accessing the mapping file in the opened state, and providing the second file descriptor to the second application program.

[0007] In combination of the first aspect and the second aspect, when a user expects to access the target file by using the second application program, the second distributed file service can first receive a second file access request of the second application program to the mapping file in the opened state, wherein the second file access request comprises a request parameter and the second file descriptor; then, send a first file access request to the first terminal device, wherein the first file access request comprises the request parameter and the index identifier of the mapping file, and the index identifier is obtained from the metadata of the mapping file according to the file identifier. The first distributed file service can correspondingly receive the first file access request from the second terminal, then query the association relationship established in the first terminal device according to the index identifier, determine the first file descriptor used for accessing the target file in the opened state, and access the target file in the opened state according to the request parameter and the first file descriptor. In this way, the second application program can complete the cross-device access to the target file stored in the first terminal device by accessing the mapping file in the opened state.

[0008] In a third aspect, the embodiments of the present application provide a file sharing method, applied to a first terminal device, the first terminal device being deployed with a first distributed file service. The method comprises: first opening a target file, the target file being a local file stored in the first terminal device and to be shared to a second terminal device, the first terminal device and the second terminal device belonging to a same distributed file system; then generating a temporary identifier and establishing an association between the temporary identifier and the target file in an open state; and then sending file sharing information containing the temporary identifier to the second terminal device.

[0009] In a fourth aspect, the embodiments of the present application provide a file sharing method corresponding to the third aspect, applied to a second terminal device, the second terminal device being deployed with a second distributed file service. The method comprises: first receiving file sharing information from a first terminal device, the first terminal device and the second terminal device belonging to a same distributed file system, the file sharing information containing a temporary identifier, the first terminal device having established an association between the temporary identifier and a target file in an open state, the target file being a local file stored in the first terminal device and to be shared to the second terminal device; then creating a temporary file in an open state in the second terminal device; then generating a second file descriptor for a second application program to access the temporary file in an open state, and providing the second file descriptor and the temporary identifier to the second application program.

[0010] In combination with the first aspect and the second aspect, when a user expects to access the target file using the second application program, the second distributed file service can first receive a second file access request of the second application program to the temporary file in an open state, the second file access request containing the second file descriptor, the temporary identifier and request parameters; then send a first file access request to the first terminal device, the first file access request containing the request parameters and the temporary identifier. The first distributed file service can correspondingly receive the first file access request from the second terminal device; then query the association according to the temporary identifier to determine the target file in an open state, and access the target file in an open state according to the request parameters. In this way, the second application program can complete cross-device access to the target file stored in the first terminal device by accessing the temporary file in an open state.

[0011] In a fifth aspect, a file sharing apparatus is provided, which is applied to a first terminal device, and the first terminal device is deployed with a first distributed file service. The apparatus comprises: a local file management unit, configured to open a target file; the target file is a local file stored in the first terminal device and to be shared to a second terminal device, and the first terminal device and the second terminal device belong to a same distributed file system; a distributed file management unit, configured to create metadata of a mapping file corresponding to the target file in the distributed file system; the metadata of the mapping file comprises a file identifier of the mapping file and an index identifier; a file descriptor transfer unit, configured to generate, for the first distributed file service, a first file descriptor used to access the target file in an open state, and establish an association relationship between the first file descriptor and the index identifier; and a data sending unit, configured to send file sharing information to the second terminal device; the file sharing information comprises the file identifier. The first distributed file service is configured to receive a first file access request from the second terminal device, the first file access request comprises a request parameter and the index identifier; query the association relationship according to the index identifier to determine the first file descriptor; and access the target file in the open state according to the request parameter and the first file descriptor.

[0012] In a sixth aspect, a file sharing apparatus corresponding to the fifth aspect is provided in the embodiments of the present application, which is applied to a second terminal device, and the second terminal device is deployed with a second distributed file service. The apparatus comprises: a data transceiving unit, configured to receive file sharing information from a first terminal device; the first terminal device and the second terminal device belong to a same distributed file system, and the file sharing information comprises a file identifier of a mapping file corresponding to a target file in the distributed file system; the target file is a local file stored in the first terminal device and to be shared to the second terminal device; a file management unit, configured to open the mapping file according to the file identifier; a file descriptor transfer unit, configured to generate, for a second application program, a second file descriptor used to access the mapping file in an open state, and provide the second file descriptor to the second application program; and the second distributed file service is configured to receive a second file access request of the second application program to the mapping file in the open state, the second file access request comprises a request parameter and the second file descriptor; send a first file access request to the first terminal device, the first file access request comprises the request parameter and an index identifier of the mapping file, and the index identifier is obtained from the metadata of the mapping file according to the file identifier.

[0013] In the seventh aspect, a file sharing device is provided, which is applied to a first terminal device, and the first terminal device deploys a first distributed file service. The device includes: a local file management unit, which is used to open a target file; wherein the target file is a local file stored in the first terminal device and to be shared with the second terminal device, and the first terminal device and the second terminal device belong to the same distributed file system. An association management unit, which is used to generate a temporary identifier, and to establish an association relationship between the temporary identifier and the target file in an open state. A data transceiver unit, which is used to send file sharing information to the second terminal device; wherein the file sharing information includes a temporary identifier. The first distributed file service is used to receive a first file access request from the second terminal device, the first file access request including a request parameter and a temporary identifier; query the association relationship based on the temporary identifier to determine the target file in an open state; and access the target file in an open state based on the request parameters.

[0014] In an eighth aspect, an embodiment of the present application provides a file sharing device corresponding to the seventh aspect, which is applied to a second terminal device, wherein a second distributed file service is deployed. The device comprises: a data transceiver unit, configured to receive file sharing information from a first terminal device; wherein the first terminal device and the second terminal device belong to the same distributed file system, the file sharing information includes a temporary identifier, and an association is established between the temporary identifier and an open target file in the first terminal device, wherein the target file is a local file stored on the first terminal device and to be shared with the second terminal device. A file management unit, configured to create an open temporary file in the second terminal device. A file descriptor transfer unit, configured to generate a second file descriptor for a second application to access the open temporary file, and to provide the second file descriptor and temporary identifier to the second application. The second distributed file service, configured to receive a second file access request from the second application for the open temporary file, the second file access request including the second file descriptor, the temporary identifier, and request parameters; and to send a first file access request to the first terminal device, wherein the first file access request includes the request parameters and the temporary identifier.

[0015] In the ninth aspect, a terminal device is provided, comprising a memory and a processor, wherein the memory stores computer program instructions / codes, and when the processor executes the computer program instructions / codes, it implements any one of the methods described in the first to fourth aspects.

[0016] In the tenth aspect, a computer-readable storage medium is provided for storing computer program instructions / codes, which, when executed by a processor of a terminal device, enables the terminal device to implement any one of the methods described in the first to fourth aspects.

[0017] In an eleventh aspect, a computer program product is provided, which includes computer program instructions / code, when the computer program instructions / code are run on a computer, causing the computer to execute the method of any one of the first aspect to the fourth aspect.

[0018] In each of the above aspects, the first distributed file service can send a metadata synchronization message to the second terminal device, the metadata synchronization message including metadata of the mapping file.

[0019] In each of the above aspects, the first terminal device can further send a file sharing request to the second terminal device, the file sharing request including a global identifier of the target file, the global identifier being a unique identifier of the target file in the first terminal device. The second terminal device can provide the file sharing request to the second application program, and in response to a triggering operation of the global identifier by a user through the second application program, send a file sharing response including the global identifier to the second terminal device. Correspondingly, the first terminal device can open the target file in response to the file sharing response from the second terminal device. In this way, the user can access the target file on demand through the second application program according to his own business needs.

[0020] In each of the above aspects, the file sharing request can further include a first application identifier of a first application program, the first application program being deployed in the first terminal device and having access authority to the target file, the first application identifier being a unique identifier of the first application program in the first terminal device. Correspondingly, the file sharing response sent by the second terminal device can further include the first application identifier. Thus, the first terminal device can open the target file through the first application program in response to the file sharing response from the second terminal device and including the global identifier and the first application identifier. In other words, the target file is opened through the first application program having access authority to the target file, ensuring that the second application program can access the target file in an open state in a subsequent process.

[0021] In each of the above aspects, the global identifier of the target file includes a uniform resource locator (URI) of the target file. The URI of the target file can specifically include a file information field, the file information field being a storage path of the target file or a mapping string corresponding to the storage path.

[0022] In each of the above aspects, the URI of the target file can further include a device information field, the device information field being a device identifier of the first terminal device or a mapping string corresponding to the device identifier.

[0023] In the above aspects, the URI of the target file further comprises an application information field, and the application information field specifically comprises a first application identifier of the first application program or a mapping string corresponding to the first application identifier.

[0024] In the above aspects, the file sharing request further comprises a second application identifier of a second application program; and the second application program is deployed in a second terminal device, and the second application identifier is a unique identifier of the second application program in the second terminal device. BRIEF DESCRIPTION OF DRAWINGS

[0025] The drawings needed to be used in the following embodiments or prior art description are briefly introduced.

[0026] Figure 1 One of the schematic diagrams for sharing a target file by different terminal devices provided in the embodiments of the present application;

[0027] Figure 2 Another of the schematic diagrams for sharing a target file by different terminal devices provided in the embodiments of the present application;

[0028] Figure 3 A flowchart of a file sharing method provided in the embodiments of the present application;

[0029] Figure 4a One of the exemplary graphical user interfaces displayed by a terminal device in the embodiments of the present application;

[0030] Figure 4b Another of the exemplary graphical user interfaces displayed by a terminal device in the embodiments of the present application;

[0031] Figure 4c A third of the exemplary graphical user interfaces displayed by a terminal device in the embodiments of the present application;

[0032] Figure 5 A flowchart of another file sharing method provided in the embodiments of the present application;

[0033] Figure 6 One of the schematic diagrams of a file sharing device provided in the embodiments of the present application;

[0034] Figure 7 Another of the schematic diagrams of a file sharing device provided in the embodiments of the present application;

[0035] Figure 8 A third of the schematic diagrams of a file sharing device provided in the embodiments of the present application;

[0036] Figure 9 A fourth of the schematic diagrams of a file sharing device provided in the embodiments of the present application;

[0037] Figure 10 FIG. 1 is a schematic diagram of a terminal device according to an embodiment of the present application. DETAILED DESCRIPTION

[0038] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.

[0039] In the embodiments of the present application, the term “and / or” is merely used to describe an associated relationship with the associated objects, and indicates that there can be three relationships; for example, “A and / or B” can indicate that there are three cases of A alone, B alone, and A and B simultaneously. The term “multiple” means two or more, and “several” means one or more, unless otherwise specified. The terms “include”, “contain”, “have” and their variants mean “include but not limited to”, unless otherwise specifically emphasized. The terms “first”, “second” are used for description purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features; therefore, the features limited by “first”, “second” can explicitly or implicitly include one or more features.

[0040] In the embodiments of the present application, the words “exemplary”, “such as” or “for example” are used to mean serving as an example, instance, or illustration, in order to present the relevant concept in a concrete manner. Any embodiment or design solution described as “exemplary”, “such as” or “for example” should not be interpreted as being more preferred or having more advantages than other embodiments or design solutions.

[0041] In the embodiments of the present application, the terminal device can be a mobile phone, a television, a sound equipment, a wearable device, a tablet computer, a personal digital assistant (PDA), a laptop, a mobile computer, an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, etc.

[0042] In terms of hardware structure, the terminal device can at least include a memory and a processor. It can also include a display screen, a camera, a communication interface, a sensor, and other modules / units for supporting the terminal device to realize information interaction with the outside world.

[0043] In terms of software structure, the software system of the terminal device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, or a cloud architecture, etc. Taking the software system of the terminal device adopting a layered architecture as an example, the software system of the layered architecture can generally be divided into four layers, from top to bottom, an application program layer, an application program framework layer, a system library and an Android runtime, and a kernel layer, each layer having a clear role and division of labor, and the layers communicate with each other through a software interface.

[0044] The application program layer includes application programs deployed in the terminal device. Exemplarily, the application program layer includes, but is not limited to, a desktop launcher (Launcher), a file manager, a file editor, etc.

[0045] The application program framework layer can provide an application programming interface (API) and a programming framework for the application program, and can also include some pre-defined function modules / services.

[0046] The system library and the Android runtime, the kernel layer, etc. can be referred to as an underlying system, and the underlying system includes function modules and hardware drivers for providing display and file management services, for example, including a surface manager located in the system library and a display driver located in the kernel layer, etc.

[0047] The runtime is responsible for the scheduling and management of the entire software system, including a core library and a virtual machine. The computer programs of the application program layer and the application program framework layer run in the virtual machine. Specifically, the virtual machine can execute the java files of the application program layer and the application program framework layer into binary files.

[0048] The system library can also include a plurality of function modules in addition to the surface manager. For example, including a state monitoring service, media libraries, a three-dimensional graphics engine (such as OpenGL for Embedded Systems), and a two-dimensional graphics engine, etc.

[0049] The kernel layer is the layer between hardware and software, including a plurality of hardware drivers, providing process management, file management, system security permission management, and system and hardware device communication basis. Exemplarily, the kernel layer can include a display driver, a camera driver, an audio driver, a touch control driver, and a plurality of local file systems.

[0050] The local file system is used to organize and allocate storage resources of the terminal device, and manage the local files stored in the storage. For example, the local file system can be responsible for creating, reading and modifying local files. In addition, the local file system can include, but is not limited to, Ext2, Ext3, Ext4 or Fuse, and the like Linux file system.

[0051] The technical solution provided in the embodiments of the present application is applicable to the following service scenario: a first application program shares a target file with a second application program, the first application program is deployed in a first terminal device, the second application program is deployed in a second terminal device, and the target file is a local file stored in the first terminal device or a distributed file.

[0052] Generally, different terminal devices each have its own system kernel and storage. The second application program deployed in the second terminal device cannot directly access the local file stored in the first terminal device. As shown in Figure 1 When the first application program (application program 2011) requests to share the target file (local file 2031) in the local file system 2021 to the second application program (application program 2012), the first terminal device (terminal device 101) needs to send the file content of the local file 2031 to the second terminal device (terminal device 102). The terminal device 102 creates and stores a local file 2032 containing the file content in the local file system 2022; the application program 2012 can access the local file 2032.

[0053] The technical solution provided in the embodiments of the present application aims to realize direct access to the target file across devices.

[0054] Figure 2 A schematic diagram of sharing the target file by different terminal devices in the embodiments of the present application is shown in Figure 2 As shown in the figure, the distributed file system 10 includes a terminal device 101 and a terminal device 102. The distributed file service 2041 is deployed in the terminal device 101, and the distributed file service 2042 is deployed in the terminal device 102. The distributed file service can be located in the application program layer or the kernel layer of the software system of the terminal device.

[0055] In the distributed file system 10, the metadata of each distributed file can be stored on the terminal device, and the metadata of each distributed file is synchronized between different terminal devices on demand or at a time. Alternatively, the distributed file system 10 further includes a master server / name node, and the metadata of each distributed file is stored in the master server. The terminal device obtains the metadata of the distributed file from the master server / name node on demand or at a time.

[0056] The distributed file system 10 can include a PVFS (parallel virtual file system), a Lustre file system, a Panfs (panasas file system), a GoogleFS (google file system), or other various types of centralized or decentralized distributed file systems, or improvements on the foregoing exemplary distributed file systems.

[0057] The terminal device 101 can also be deployed with a file sharing apparatus 61, and the terminal device 102 can also be deployed with a file sharing apparatus 62, so that the terminal device 101 and the terminal device 102 can cooperate with each other to support the application 2012 to access the local file 2031 across devices according to their respective deployed distributed file services.

[0058] Based on the system framework as shown in Figure 2 , an embodiment of the present application provides a file sharing method. As Figure 3 indicated, the method can include but is not limited to some or all of the steps as shown in Figure 3 .

[0059] In step 301, the terminal device 101 acquires configuration information of the terminal device 102.

[0060] The terminal device 101 can receive the configuration information of the terminal device 102 from the terminal device 102. Similarly, the terminal device 101 can send its own configuration information to other terminal devices in the distributed file system 10.

[0061] The configuration information of the terminal device 102 at least includes a device identifier of the terminal device 102. The device identifier of the terminal device 102 can be an internet protocol (IP) address or a media access control address (MAC) of the terminal device 102.

[0062] In some embodiments, the configuration information of the terminal device 102 can also include application identifiers of several application programs deployed in the terminal device 102. The application identifier of an application program can be the name of the installation package of the application program or a unique identifier assigned to the application program. In addition, for any application program deployed in the terminal device 102, if the application program has the permission to access the distributed file, i.e., has the permission to call the distributed file service 2042, the application identifier of the application program is included in the configuration information of the terminal device 102.

[0063] In step 3021 , the terminal device 101 determines the local file 2031 as the target file to be shared.

[0064] In step 3022 , the terminal device 101 determines the terminal device 102 for accessing the target file.

[0065] In some embodiments, the terminal device 101 runs an application 2011 and displays a graphical user interface of the application 2011. The user can perform business operations in the graphical user interface, and the file sharing device 61 deployed in the terminal device 101 determines the target file to be shared and the terminal device 102 used to access the target file based on the business operations performed by the user in the graphical user interface.

[0066] For example, terminal device 101 may be a mobile phone, and terminal device 102 may be a tablet computer; application 2011 may be a file manager, and application 2012 may be a file editor. The file manager has access permissions to both local files named "File 1" and "File 2," and the user wishes to share local file 2031 named "File 1" on the mobile phone with the file editor on the tablet computer, and edit local file 2031 using the file editor on the tablet computer.

[0067] First, the phone can display the file manager as follows Figure 4a The user can press and hold the area where the word "File 1" is located to determine the local file 2031 named "File 1" as the target file to be shared.

[0068] Then, the terminal device 101 displays the following Figure 4b The graphical user interface shown. The graphical user interface can not only list various local files and indicate the determined target file, but also display icons or words for supporting various specific types of management of the target file. For example, a "Share" icon for supporting sharing of the target file with other users through a specified communication method, a "Copy" icon for supporting copying the target file, a "Move" icon for moving the target file to change the storage path of the target file, and the words "Open with" and "Rename" under the "More" list item, where the word "Rename" is used to support modifying the file name of the target file, and the word "Open with" is used to support initiating sharing of the target file.

[0069] Then, the user can touch / press the words "Open in" to make the terminal device display the following Figure 4cThe graphical user interface shown. Assume that the graphical user interface shows the current device, device 1 and device 2, among which device 1 represents the device name of the tablet computer, wherein the device name of the terminal device corresponds to the device identification of the terminal device. Based on this assumption, the user can determine the tablet computer as the terminal device 102 for accessing the target file by pressing / touching the area where the "device 1" word is located.

[0070] When the configuration information of the terminal device 102 contains several application identifications, similar to the foregoing determination of the terminal device 102 for accessing the target file, after the user selects "device 1" as the terminal device 102 for accessing the target file, Figure 4c The graphical user interface shown can also display the application identifications contained in the configuration information of "device 1", such as "photos", "file editor" and "PDF", etc. These application identifications are. The user can further touch / press the area where "file editor" is located, so that the "file editor" deployed in the tablet computer is determined as the application program 2012 for accessing the target file.

[0071] It should be noted that, Figure 4a , Figure 4b and Figure 4c are only used to assist in describing the technical solutions provided in the embodiments of the present application, and the graphical user interface for determining the target file to be shared, the terminal device 102 for accessing the target file, and the application program 2012 for accessing the target file can also have other layouts and page jump relationships. In addition, step 3021 can be performed first, and then step 3022 can be performed; for example, an icon associated with the file sharing device 61 can be set in one graphical user interface of the application program 2011, and the user can touch / press the icon in the graphical user interface, so that the terminal device 101 displays another graphical user interface under the support of the file sharing device 61, and the user can perform corresponding business operations in the another graphical user interface, so that the terminal device 101 determines the target file to be shared, the graphical user interface of the terminal device 102 for accessing the target file, and the application program 2012 for accessing the target file, etc.

[0072] When the configuration information of the terminal device 102 contains several application identifications, similar to the foregoing determination of the terminal device 102 for accessing the target file, the terminal device 101 can also display an application selection interface through the file sharing device 61. According to the application selection operation performed by the user in the application selection interface, the application program 2012 for accessing the target file is determined. Among them, the application selection interface can display each application identification contained in the configuration information of the terminal device 102.

[0073] In step 303, the terminal device 101 determines a global identifier of the target file. The global identifier of the target file is a unique identifier of the target file in the terminal device 101, and is used to support searching of the target file.

[0074] In some embodiments, the global identifier of the target file can be a storage path of the target file, or a mapping string corresponding to the storage path.

[0075] In some embodiments, the global identifier of the target file can be a URI of the target file. The URI of the target file is at least used to identify a name / location string of the target file in the terminal device 101.

[0076] For example, the URI of the target file specifically includes a device information field and a file information field.

[0077] For example, the URI of the target file specifically includes a device information field, an application information field and a file information field.

[0078] In each of the above examples, the file information field can be a storage path of the target file, or a mapping string corresponding to the storage path.

[0079] In each of the above examples, the device information field can be a device identifier of the terminal device 101, or a mapping string corresponding to the device identifier. The device identifier of the terminal device 101 can specifically be an IP address of the terminal device 101, or other identifiers that can be resolved by a domain name system (DNS) based on the IP address / MAC address of the terminal device 101.

[0080] In each of the above examples, the application information field can be an application identifier of the application program 2011 requesting to share the target file, or a mapping string corresponding to the application identifier.

[0081] Based on each of the above examples, the URI of the target file can further include a protocol identifier (for example, http, ftp, mailto or file), and other terminal devices including the terminal device 102 can perform access operations on the target file based on the protocol identifier included in the URI of the target file through a corresponding communication protocol.

[0082] In step 304, the terminal device 101 sends a file sharing request to the terminal device 102.

[0083] The file sharing request includes the global identifier of the target file.

[0084] If the terminal device 101 determines that the application 2012 is an application for accessing the shared file, the file sharing request can further include an application identifier of the application 2012.

[0085] The terminal device 101 can complete the above steps 301 to 304 with the support of the file sharing apparatus 61.

[0086] After receiving the file sharing request, the terminal device 102 performs step 305, runs the application 2012 and provides the file sharing request to the application 2012.

[0087] The application 2012 for accessing the target file can be determined by the terminal device 101.

[0088] The application 2012 for accessing the target file can be autonomously selected by the user holding the terminal device 102, or pre-determined by the terminal device 102.

[0089] In other words, the file sharing apparatus 62 in the terminal device 10 can trigger the terminal device 102 to start and run the application 2012 according to the application identifier of the application 2012 contained in the file sharing request received by the file sharing apparatus 62, or according to the application identifier of the application 2012 pre-set by the file sharing apparatus 62, or according to the application identifier of the application 2012 selected by the user. Then, the file sharing apparatus 62 can provide the file sharing request to the application 2012 according to the application identifier of the application 2012. Finally, the global identifier of the target file contained in the file sharing request is presented through the graphical user interface of the application 2012. In this way, the user can obtain one or more of the following information: the terminal device that requests to share the target file with the user, the application that requests to share the target file with the user, and the target file that needs to be shared. In addition, the user can also perform a triggering operation on the global identifier of the target file in the graphical user interface of the application 2012, such as touching / clicking the area where the global identifier is located in the graphical user interface, to respond to the file sharing request from the terminal device 101.

[0090] The terminal device 102 can respond to the triggering operation of the user on the global identifier of the target file to perform step 306, and send a file sharing response to the terminal device 101 with the support of the file sharing apparatus 62.

[0091] The file sharing response includes the global identifier of the target file.

[0092] The terminal device 101 can open the target file according to the global identifier of the target file with the support of the file sharing apparatus 61 in response to the file sharing response from the terminal device 102 to perform step 307.

[0093] In some embodiments, the terminal device 101 resolves the global identifier from the terminal device 102 through the file sharing apparatus 61, determines the application program 2011 requesting the sharing of the target file according to the application information field in the global identifier, and finds the target file stored in the terminal device 101 according to the file information field in the global identifier. Then, the application program 2011 is triggered through the file sharing apparatus 61 to request the system kernel of the terminal device 101 to open the target file.

[0094] In which, the system kernel of the terminal device 101 can create a file structure body of the target file according to the file opening request of the application program 2011 to the target file. The file structure body of the target file represents the target file in an open state.

[0095] It should be noted that if the target file is an internal file of the application program 2011, the target file can be first converted from an internal file of the application program 2011 to a public file accessible by other application programs according to the application information field in the global identifier of the target file, and then the target file converted to the public file is opened by the application program 2011. Taking the terminal device 101 using an Android-based software system as an example, the internal file of the application program 2011 can be converted to a public file through the provider mechanism provided by the terminal device 101.

[0096] Then, the terminal device 101 performs step 3081 to create the metadata of the mapping file corresponding to the target file in the distributed file system 10 through the distributed file service 2041.

[0097] Specifically, the file sharing apparatus 61 in the terminal device 101 can call the distributed file service 2041 to complete the creation of the metadata of the mapping file corresponding to the target file in the distributed file system 10.

[0098] The metadata of the mapping file can include the file identifier of the mapping file in the distributed file system 10, the index identifier (or handle) for supporting the access to the mapping file, and the device identifier of the terminal device 101.

[0099] The file identifier of the mapping file can include the path of the mapping file in the directory tree of the distributed file system 10. For example, the root directory of the directory tree of the distributed file system is "AA", the root directory "AA" includes a first-level subdirectory "BB". When the terminal device 101 creates the metadata of the mapping file, a second-level subdirectory "CC" is created under the first-level subdirectory "BB". Therefore, the file identifier of the mapping file can be "AA / BB / CC".

[0100] The directory tree of the distributed file system can be maintained by the user, that is, the file identifier of the distributed file can be created or modified by the user independently, and therefore the file identifier of the distributed file is usually not used as the unique identifier of the distributed file. When maintaining the file identifier of the mapping file in the distributed file system 10, the distributed file service 2041 can assign an index identifier to the mapping file according to a predetermined strategy, and the index identifier is the unique identifier of the mapping file in the distributed file system.

[0101] Therefore, from the perspective of the application program on the user side, a file access request for accessing the mapping file can be initiated to the distributed file service according to the file identifier of the mapping file; from the perspective of the distributed file system 10, the distributed file service 2042 can access the mapping file according to the index identifier of the mapping file.

[0102] It should be noted that after the metadata of the mapping file corresponding to the target file is created, the file content of the mapping file is not actually written in the distributed file system 10, but the index identifier of the mapping file and the target file in the open state are associated in the subsequent process, so that the file content of the target file in the open state is used as the file content of the mapping file. Therefore, when the application program accesses the mapping file, it actually accesses the target file.

[0103] Next, the terminal device 102 performs step 3082 to receive a metadata synchronization message.

[0104] The metadata synchronization message includes the metadata of the mapping file corresponding to the target file.

[0105] Depending on the architecture of the distributed file system 10, the specific implementation process of step 3081 and step 3082 can be different.

[0106] In one example, the metadata of the distributed file is managed by the terminal device 101. The metadata of the mapping file corresponding to the target file can be created independently by the distributed file service 2041 in step 3081, and the metadata of the mapping file is sent to the distributed file service 2042.

[0107] In one example, the terminal device 101 only serves as a data node for storing the distributed file in the distributed file system 10, and the metadata of the distributed file is uniformly managed by the master server. In step 3081, the metadata of the mapping file corresponding to the target file can be created in the master server by the distributed file service 2041 interacting with the master server / other terminal devices; in step 3082, the metadata synchronization message can be received by the distributed file service 2042 from the master server / other terminal devices.

[0108] Then, the terminal device 101 performs step 309, generates a first file descriptor for accessing the target file in the open state for the distributed file service 2041, and establishes an association between the first file descriptor and the index identifier.

[0109] Specifically, the file descriptor table of the distributed file service 2041 can be searched to learn the file descriptors that have been occupied by the distributed file service 2041. Then, a first file descriptor that has not been occupied by the distributed file service 2041 is generated. Finally, the first file descriptor is associated with the file structure of the target file in the file descriptor table, and the first file descriptor is returned to the distributed file service 2041, thereby completing the generation of the first file descriptor for accessing the target file in the open state for the distributed file service 2041.

[0110] Then, the terminal device 101 performs step 310, and sends the file sharing information to the terminal device 102.

[0111] The file sharing information can include the file identifier of the mapping file.

[0112] In some embodiments, the file sharing information can further include the application identifier of the application 2012.

[0113] The terminal device 102 can receive the file sharing information through the file sharing apparatus 62, and perform step 311, open the mapping file according to the file identifier of the mapping file, generate a second file descriptor for accessing the mapping file in the open state for the application 2012, and provide the second file descriptor to the application 2012.

[0114] Specifically, first, the file sharing apparatus 62 can receive the file sharing information from the terminal device 101. Then, the file sharing apparatus 62 can call the distributed file service 2042 to open the mapping file according to the file identifier of the mapping file. Then, a second file descriptor for accessing the mapping file in the open state for the application 2012 is generated by a method similar to the aforementioned generation of the first file descriptor for accessing the target file in the open state for the distributed file service 2041. In this way, the application 2012 can access the mapping file in the open state through the second file descriptor. Since the file content of the mapping file is essentially the file content of the target file in the open state, the access to the mapping file by the application 2012 is essentially the access to the target file, i.e., the access to the local file 2031 stored in the terminal device 101.

[0115] It should be noted that the distributed file service 2042 can determine the index identifier of the mapping file from the metadata of the mapping file according to the file identifier of the mapping file when the terminal opens the mapping file. Then, the terminal device 102 receives the file access request of the application 2012 to the mapping file in the open state through the distributed file service 2042 in step 312.

[0116] The file access request includes the second file descriptor and the corresponding request parameter. The request parameter can include the file access type or the type indication information indicating the file access type, such as including "read" or "write", or including the type indication information indicating that the file access type is "read" or "write". When the file access type is "write", the request parameter can further include the file content to be written.

[0117] The terminal device 102 then sends the file access request to the terminal device 101 through the distributed file service 2042 in step 313. The file access request includes the index identifier of the mapping file and the request parameter included in the file access request of the application 2012.

[0118] The terminal device 101 receives the file access request from the distributed file service 2042 through the distributed file service 2041, and then determines the first file descriptor associated with the index identifier of the mapping file through the distributed file service 2041 in step 314, and accesses the target file in the open state according to the first file descriptor and the request parameter.

[0119] Specifically, the distributed file service 2041 can determine the first file descriptor for accessing the target file in the open state from the established association relationship according to the index identifier of the mapping file included in the file access request. Then, according to the file access type and the first file descriptor included in the request parameter, the interface function corresponding to the file access type in the system kernel is called, so that the interface function finds the file structure body of the target file from the file descriptor table of the distributed file service 2041 according to the first file descriptor, and then accesses the target file based on the found file structure body.

[0120] Based on the system framework as shown in Figure 2 Another file sharing method is provided in the embodiment of the present application. As shown in Figure 5 The method can include but is not limited to some or all of the steps as shown in Figure 5 .

[0121] Unlike the method as shown in Figure 3The embodiment shown is that after step 307, the terminal device 101 performs step 508, generates a temporary identifier, and establishes an association between the temporary identifier and the target file in the open state.

[0122] Specifically, the file structure of the target file represents the target file in the open state. The temporary identifier is a unique identifier of the file structure of the target file in the terminal device 101. The association between the temporary identifier and the file structure of the target file can be established, and the association between the temporary identifier and the target file in the open state can be completed.

[0123] Then, the terminal device 101 performs step 509, and sends the file sharing information to the terminal device 102.

[0124] The file sharing information at least includes the temporary identifier, and optionally includes the application identifier of the application 2012.

[0125] After the terminal device 102 receives the file sharing information from the terminal device 101, it performs step 510, and creates a temporary file in the open state through the distributed file service 2042.

[0126] Specifically, the terminal device 101 can receive the file sharing information through the file sharing device 62. Then, the file sharing device 62 can send a file opening request to the distributed file service 2042, the file opening request including the indication information and the file identifier of the predetermined distributed file, the indication information being used to instruct the distributed file service 2042 to create a temporary file without a name, i.e., to instruct the distributed file service to create a file structure without a name.

[0127] Then, the terminal device 102 performs step 511, generates a second file descriptor for the application 2012 to access the temporary file in the open state, and provides the temporary identifier and the second file descriptor to the application 2012.

[0128] The terminal device 102 can generate the second file descriptor for the application 2012 to access the temporary file in the open state through a method similar to the aforementioned method of generating the first file descriptor for the application 2011 to access the target file in the open state. The predetermined distributed file can be the root directory of the distributed file system 10, or other distributed files in the distributed file system 10.

[0129] Then, the terminal device 102 performs step 512, and receives a file access request of the application 2012 to the temporary file in the open state through the distributed file service 2042.

[0130] The file access request includes a temporary identifier, a second file descriptor, and corresponding request parameters.

[0131] Next, in step 513, the terminal device 102 sends a file access request to the terminal device 101 via the distributed file service 2032. The file access request includes a temporary identifier and corresponding request parameters.

[0132] After receiving the file access request from the distributed file service 2042 through the distributed file service 2041, the terminal device 101 executes step 514, determines the open target file associated with the temporary identifier through the distributed file service 2041, and accesses the open target file according to the request parameters.

[0133] Specifically, the distributed file service can determine the target file in the open state from the established association relationship based on the temporary identifier included in the file access request, that is, determine the file structure of the target file. Then, based on the file access type included in the request parameters, the interface function corresponding to the file access type in the system kernel is called, so that the interface function performs access operations on the target file based on the file structure of the target file.

[0134] In some embodiments, the system kernel of the terminal device 101 may also close the open target file in response to the file close request of the application 2011. That is, the file structure of the target file is deleted from the terminal device 101, so that the application 2012 cannot continue to access the target file across devices.

[0135] Based on the same concept as the above method embodiment, the present application embodiment also provides a file sharing device, which can be used as a file sharing device 61 and deployed in the terminal device 101 as the first terminal device. Figure 6 As shown, the apparatus may include: a local file management unit 611, for opening a target file; wherein, the target file is a local file stored in the first terminal device and to be shared with the second terminal device, and the first terminal device and the second terminal device belong to the same distributed file system. A distributed file management unit 612, for creating metadata of a mapping file corresponding to the target file in the distributed file system; wherein, the metadata of the mapping file includes a file identifier and an index identifier of the mapping file. A file descriptor transfer unit 613, for serving the first distributed file, generating a first file descriptor for accessing the target file in an open state, and establishing an association between the first file descriptor and the index identifier. A data sending unit 614, for sending file sharing information to the second terminal device; wherein, the file sharing information includes the file identifier.

[0136] Based on the same idea as the foregoing method embodiments, another file sharing device is also provided in the embodiments of the present application, which can be deployed in the terminal device 101 as the first terminal device as the file sharing device 61. As shown in Figure 7 The device can include: a local file management unit 615, configured to open a target file; wherein the target file is a local file stored in the first terminal device and to be shared to a second terminal device, and the first terminal device and the second terminal device belong to the same distributed file system. An association relationship management unit 616, configured to generate a temporary identifier, and establish an association relationship between the temporary identifier and the target file in an open state. A data transceiving unit 617, configured to send file sharing information to the second terminal device; wherein the file sharing information includes the temporary identifier.

[0137] Based on the same idea as the foregoing method embodiments, another file sharing device is also provided in the embodiments of the present application, which can be deployed in the terminal device 102 as the second terminal device as the file sharing device 62. As shown in Figure 8 The device includes: a data transceiving unit 621, configured to receive file sharing information from a first terminal device; wherein the first terminal device and the second terminal device belong to the same distributed file system, and the file sharing information includes a file identifier of a mapping file corresponding to a target file in the distributed file system, and the target file is a local file stored in the first terminal device and to be shared to the second terminal device. A file opening unit 622, configured to open the mapping file according to the file identifier. A file descriptor passing unit 623, configured to generate a second file descriptor for accessing the mapping file in an open state for a second application program, and provide the second file descriptor to the second application program.

[0138] Based on the same idea as the foregoing method embodiments, another file sharing device is also provided in the embodiments of the present application, which can be deployed in the terminal device 102 as the second terminal device as the file sharing device 62. As shown in Figure 9As shown, the apparatus comprises: a data transceiving unit 624, configured to receive file sharing information from a first terminal device; wherein the first terminal device and the second terminal device belong to the same distributed file system, and the file sharing information comprises a temporary identifier, and the first terminal device has established an association relationship between the temporary identifier and a target file in an open state, and the target file is a local file stored in the first terminal device and to be shared to the second terminal device. A file management unit 625, configured to create a temporary file in an open state in the second terminal device. A file descriptor passing unit 626, configured to generate a second file descriptor for accessing the temporary file in an open state for a second application program, and provide the second file descriptor and the temporary identifier to the second application program.

[0139] In the above various aspects, the first distributed file service can send a metadata synchronization message to the second terminal device, and the metadata synchronization message comprises metadata of the mapping file.

[0140] In the above various aspects, the first terminal device can further send a file sharing request to the second terminal device, and the file sharing request comprises a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device. The second terminal device can provide the file sharing request to the second application program, and in response to a trigger operation of the user on the global identifier through the second application program, send a file sharing response comprising the global identifier to the second terminal device. Correspondingly, the first terminal device can open the target file in response to the file sharing response from the second terminal device. In this way, the user can access the target file on demand through the second application program according to its own business needs.

[0141] In the above various file sharing apparatuses, the file sharing request can further comprise a first application identifier of a first application program, and the first application program is deployed in the first terminal device and has the permission to access the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device. Correspondingly, the file sharing response can further comprise the first application identifier. The file sharing apparatus in the first terminal device can open the target file through the first application program in response to the file sharing response comprising the global identifier and the first application identifier.

[0142] In the above various file sharing apparatuses, the global identifier of the target file comprises a URI of the target file. The URI of the target file can specifically comprise a file information field, and the file information field is a storage path of the target file or a mapping string corresponding to the storage path.

[0143] In the above various file sharing apparatuses, the URI of the target file further comprises a device information field, and the device information field is a device identifier of the first terminal device or a mapping string corresponding to the device identifier.

[0144] In the above various file sharing apparatuses, the URI of the target file further comprises an application information field, and the application information field specifically comprises a first application identifier of the first application program or a mapping string corresponding to the first application identifier.

[0145] In the above various file sharing apparatuses, the file sharing request further comprises a second application identifier of a second application program; the second application program is deployed in a second terminal device, and the second application identifier is a unique identifier of the second application program in the second terminal device.

[0146] Those skilled in the art can appreciate that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solutions. Those skilled in the art can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of the present application. Therefore, the embodiments of the present application also provide a terminal device and a computer readable storage medium.

[0147] As shown in Figure 10 , the terminal device 100 can include a processor 1001, a memory 1002, and a communication interface 1003. The communication interface 1003 is configured to communicate with other terminal devices. The memory 1002 stores computer program instructions / code, and when the processor 1001 executes the computer program instructions / code, the terminal device 100: as a terminal device 101, implements the method performed by the terminal device 101 in the embodiments as shown in Figure 3 or Figure 5 ; or as a terminal device 102, implements the method performed by the terminal device 102 in the embodiments as shown in Figure 3 or Figure 5 .

[0148] The computer readable storage medium is configured to store computer program instructions / code, which, when executed by the processor of the terminal device, causes the terminal device: as a terminal device 101, to implement the method performed by the terminal device 101 in the embodiments as shown in Figure 3 or Figure 5 ; or as a terminal device 102, to implement the method performed by the terminal device 102 in the embodiments as shown in Figure 3 or Figure 5 .

[0149] It should be understood that the magnitude of the sequence number of each process described above does not mean the order of execution in various embodiments of the embodiments of the present application. The execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0150] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the network device can be referred to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0151] It can be understood that the device embodiments described above are illustrative, for example, the division of the modules / units is only a logical function division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0152] The above is only a specific implementation of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited to this, any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the embodiments of the present application, which should be covered in the protection scope of the embodiments of the present application

[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions provided in the foregoing embodiments can still be modified, or some technical features can be replaced, and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions provided in the embodiments of the present application.

Claims

1. A file sharing method characterized by, Applied to a first terminal device, the first terminal device is deployed with a first distributed file service, comprising: opening a target file; wherein the target file is a local file stored in the first terminal device and to be shared to a second terminal device, the first terminal device and the second terminal device belong to the same distributed file system; in the distributed file system, creating metadata of a mapping file corresponding to the target file; wherein the metadata of the mapping file comprises a file identifier and an index identifier of the mapping file; for the first distributed file service, generating a first file descriptor for accessing the target file in an open state, and establishing an association relationship between the first file descriptor and the index identifier; sending file sharing information to the second terminal device; wherein the file sharing information comprises the file identifier; the second terminal device comprises a second distributed file service and a second application program, the second terminal device is used to open the mapping file according to the file identifier, and provide a second file descriptor to the second application program; the second application program is used to access the mapping file according to the second file descriptor; the second distributed file service is used to send a first file access request to the first terminal device according to the second file descriptor; through the first distributed file service, receiving a first file access request from the second terminal device, the first file access request comprises a request parameter and the index identifier; according to the index identifier, the association relationship is queried, and the first file descriptor is determined; according to the request parameter and the first file descriptor, the target file in the open state is accessed.

2. The method of claim 1, wherein, Further comprising: sending a metadata synchronization message to the second terminal device through the first distributed file service; wherein the metadata synchronization message comprises the metadata of the mapping file.

3. The method of claim 1, wherein, Further comprising: sending a file sharing request to the second terminal device; wherein the file sharing request comprises a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device; the opening target file specifically comprises: opening the target file in response to a file sharing response from the second terminal device and comprising the global identifier.

4. The method of claim 3, wherein the file sharing request further comprises a first application identifier of a first application; wherein the first application is deployed in the first terminal device and has the permission to access the target file, and the first application identifier is a unique identifier of the first application in the first terminal device; the opening target file in response to a file sharing response from the second terminal device and comprising the global identifier of the target file specifically comprises: opening the target file through the first application in response to a file sharing response from the second terminal device and comprising the global identifier and the first application identifier.

5. The method of claim 3, wherein The global identifier of the target file includes a uniform resource locator (URI) of the target file; and the URI of the target file specifically includes a file information field, which is a storage path of the target file or a mapping string corresponding to the storage path.

6. The method of claim 5, wherein, The URI of the target file further includes: a device information field, which specifically includes a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or, an application information field, which specifically includes a first application identifier of a first application program or a mapping string corresponding to the first application identifier.

7. A file sharing method characterized by, The first terminal device is applied to, and the first terminal device deploys a first distributed file service, including: opening a target file; wherein the target file is a local file stored in the first terminal device and to be shared to a second terminal device, and the first terminal device and the second terminal device belong to a same distributed file system; generating a temporary identifier, and establishing an association relationship between the temporary identifier and the target file in an open state; sending file sharing information to the second terminal device; wherein the file sharing information includes the temporary identifier; the second terminal device includes a second distributed file service and a second application program, and the second terminal device is configured to create a temporary file in an open state, generate a second file descriptor for accessing the temporary file in an open state for the second application program, provide the second file descriptor and the temporary identifier to the second application program, and send a first file access request to the first terminal device through the second distributed file service after the second application program accesses the temporary file; receiving, through the first distributed file service, a first file access request from the second terminal device, the first file access request including a request parameter and the temporary identifier; querying the association relationship according to the temporary identifier to determine the target file in an open state; and accessing the target file in an open state according to the request parameter.

8. The method of claim 7, wherein, Further including: sending a file sharing request to the second terminal device; wherein the file sharing request includes a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device; the opening of the target file specifically includes: in response to a file sharing response from the second terminal device and including the global identifier, opening the target file.

9. The method of claim 8, wherein: the file sharing request further includes a first application identifier of a first application program; wherein the first application program is deployed in the first terminal device and has a permission to access the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device. The opening the target file in response to the file sharing response from the second terminal device and comprising the global identifier of the target file specifically comprises: opening the target file through the first application program in response to the file sharing response from the second terminal device and comprising the global identifier and the first application identifier.

10. The method of claim 8, wherein, The global identifier of the target file comprises a uniform resource locator (URI) of the target file; and the URI of the target file specifically comprises a file information field, which is a storage path of the target file or a mapping string corresponding to the storage path.

11. The method of claim 10, wherein, The URI of the target file further comprises: a device information field, which specifically comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or an application information field, which specifically comprises a first application identifier of the first application program or a mapping string corresponding to the first application identifier. The second terminal device, in which a second distributed file service is deployed, comprises:

12. A file sharing method characterized by, receiving file sharing information from a first terminal device; wherein the first terminal device and the second terminal device belong to the same distributed file system, and the file sharing information comprises a file identifier of a mapping file corresponding to a target file in the distributed file system, the target file being a local file stored in the first terminal device and to be shared to the second terminal device; before sending the file sharing information, the first terminal device creates metadata of the mapping file corresponding to the target file in the distributed file system, wherein the metadata of the mapping file comprises a file identifier of the mapping file and an index identifier, and an association relationship between a first file descriptor and the index identifier is established; opening the mapping file according to the file identifier; generating a second file descriptor for a second application program to access the mapping file in an open state, and providing the second file descriptor to the second application program; receiving, through the second distributed file service, a second file access request of the second application program to the mapping file in the open state, the second file access request comprising a request parameter and the second file descriptor; sending a first file access request to the first terminal device, the first file access request comprising the request parameter and the index identifier of the mapping file, the index identifier being obtained from the metadata of the mapping file according to the file identifier; the first terminal device is further configured to query the association relationship according to the index identifier to determine the first file descriptor, and access the target file in the open state according to the request parameter and the first file descriptor. Further comprising:

13. The method of claim 12, wherein, receiving, through the second distributed file service, a metadata synchronization message from the first terminal device; wherein the metadata synchronization message comprises the metadata of the mapping file. Further comprising:

14. The method of claim 12, wherein, ​ receiving a file sharing request from the first terminal device; wherein the file sharing request comprises a global identifier of the target file, the global identifier being a unique identifier of the target file in the first terminal device; providing the file sharing request to the second application program; in response to a triggering operation of the global identifier by a user through the second application program, sending a file sharing response to the second terminal device; wherein the file sharing response comprises the global identifier.

15. The method of claim 14, wherein: the file sharing request further comprises a first application identifier of a first application program; wherein the first application program is deployed in the first terminal device and has a permission to access the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device; the file sharing response further comprises the first application identifier.

16. The method of claim 14, wherein: the global identifier of the target file comprises a uniform resource identifier (URI) of the target file; wherein the URI of the target file specifically comprises a file information field, and the file information field is a storage path of the target file or a mapping string corresponding to the storage path.

17. The method of claim 16, wherein, the URI of the target file further comprises: a device information field, which specifically comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or an application information field, which specifically comprises a first application identifier of the first application program or a mapping string corresponding to the first application identifier. applicable to a second terminal device, the second terminal device deploying a second distributed file service, comprising:

18. A file sharing method characterized by, receiving file sharing information from a first terminal device; wherein the first terminal device and the second terminal device belong to a same distributed file system, the file sharing information comprising a temporary identifier, and the first terminal device establishing an association relationship between the temporary identifier and a target file in an open state, the target file being a local file stored in the first terminal device and to be shared to the second terminal device; before sending the file sharing information, the first terminal device is configured to generate a temporary identifier and establish an association relationship between the temporary identifier and the target file in an open state; creating a temporary file in an open state in the second terminal device; generating a second file descriptor for a second application program to access the temporary file in an open state, and providing the second file descriptor and the temporary identifier to the second application program; receiving, through the second distributed file service, a second file access request of the second application program to the temporary file in an open state, the second file access request comprising the second file descriptor, the temporary identifier and a request parameter. ​ sending a first file access request to the first terminal device, wherein the first file access request comprises the request parameter and the temporary identifier, and the first terminal device is further configured to receive the first file access request through the first distributed file service, query the association relationship according to the temporary identifier, determine the target file in the open state, and access the target file in the open state according to the request parameter.

19. The method of claim 18, wherein, Further comprising: receiving a file sharing request from the first terminal device; wherein the file sharing request comprises a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device; providing the file sharing request to the second application program; sending a file sharing response to the second terminal device in response to a triggering operation of the global identifier by a user through the second application program; wherein the file sharing response comprises the global identifier.

20. The method of claim 19, wherein the file sharing request further comprises a first application identifier of a first application program; wherein the first application program is deployed in the first terminal device and has a permission to access the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device; the file sharing response further comprises the first application identifier.

21. The method of claim 19, wherein the global identifier of the target file comprises a uniform resource identifier (URI) of the target file; wherein the URI of the target file specifically comprises a file information field, and the file information field is a storage path of the target file or a mapping string corresponding to the storage path.

22. The method of claim 21, wherein, the URI of the target file further comprises: a device information field, which specifically comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or an application information field, which specifically comprises a first application identifier of a first application program or a mapping string corresponding to the first application identifier. The device is applied to a first terminal device, wherein the first terminal device deploys a first distributed file service, and the device comprises:

23. A file sharing apparatus, characterized by comprising: a local file management unit configured to open a target file; wherein the target file is a local file stored in the first terminal device and to be shared to a second terminal device, and the first terminal device and the second terminal device belong to a same distributed file system; a distributed file management unit configured to create metadata of a mapping file corresponding to the target file in the distributed file system; wherein the metadata of the mapping file comprises a file identifier of the mapping file and an index identifier; a file descriptor transmission unit configured to generate a first file descriptor for accessing the target file in the open state for the first distributed file service, and establish an association relationship between the first file descriptor and the index identifier. ​ a data sending unit, configured to send file sharing information to the second terminal device; wherein the file sharing information comprises the file identifier, the second terminal device comprises a second distributed file service and a second application program, and the second terminal device is configured to open the mapping file according to the file identifier and provide a second file descriptor to the second application program; the second application program is configured to access the mapping file according to the second file descriptor; and the second distributed file service is configured to send a first file access request to the first terminal device according to the second file descriptor. The first distributed file service is configured to receive a first file access request from the second terminal device, wherein the first file access request comprises a request parameter and the index identifier; query the association relationship according to the index identifier to determine the first file descriptor; and access the target file in the opened state according to the request parameter and the first file descriptor.

24. The apparatus of claim 23, wherein, The first distributed file service is further configured to send a metadata synchronization message to the second terminal device, wherein the metadata synchronization message comprises metadata of the mapping file.

25. The apparatus of claim 23, wherein The data transceiver is further configured to send a file sharing request to the second terminal device, wherein the file sharing request comprises a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device. The local file management unit is specifically configured to open the target file in response to a file sharing response from the second terminal device and comprising the global identifier.

26. The apparatus of claim 25, wherein The file sharing request further comprises a first application identifier of a first application program; wherein the first application program is deployed in the first terminal device and has a permission to access the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device. The local file management unit is specifically configured to open the target file through the first application program in response to a file sharing response from the second terminal device and comprising the global identifier and the first application identifier.

27. The apparatus of claim 25, wherein The global identifier of the target file comprises a uniform resource locator (URI) of the target file; wherein the URI of the target file specifically comprises a file information field, and the file information field is a storage path of the target file or a mapping string corresponding to the storage path.

28. The apparatus of claim 27, wherein, The URI of the target file further comprises: a device information field, which specifically comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or an application information field, which specifically comprises a first application identifier of a first application program or a mapping string corresponding to the first application identifier. ​ 29. A file sharing apparatus, characterized by comprising: Applied to a first terminal device, the first terminal device is deployed with a first distributed file service, and the apparatus comprises: a local file management unit configured to open a target file, wherein the target file is a local file stored in the first terminal device and to be shared to a second terminal device, the first terminal device and the second terminal device belong to a same distributed file system; an association relationship management unit configured to generate a temporary identifier and establish an association relationship between the temporary identifier and the target file in an open state; a data transceiving unit configured to send file sharing information to the second terminal device, wherein the file sharing information comprises the temporary identifier, the second terminal device comprises a second distributed file service and a second application program, the second terminal device is configured to create a temporary file in an open state, generate a second file descriptor for accessing the temporary file in an open state for the second application program, provide the second file descriptor and the temporary identifier to the second application program, and send a first file access request to the first terminal device through the second distributed file service after the second application program accesses the temporary file; wherein the first distributed file service is configured to receive a first file access request from the second terminal device, the first file access request comprises a request parameter and the temporary identifier; query the association relationship according to the temporary identifier to determine the target file in an open state; and access the target file in an open state according to the request parameter.

30. The apparatus of claim 29, wherein the data transceiving unit is further configured to send a file sharing request to the second terminal device, wherein the file sharing request comprises a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device; the local file management unit is specifically configured to open the target file in response to a file sharing response from the second terminal device and comprising the global identifier.

31. The apparatus of claim 30, wherein the file sharing request further comprises a first application identifier of a first application program, wherein the first application program is deployed in the first terminal device and has a permission to access the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device; the local file management unit is specifically configured to open the target file through the first application program in response to a file sharing response from the second terminal device and comprising the global identifier and the first application identifier.

32. The apparatus of claim 30, wherein the global identifier of the target file comprises a uniform resource identifier (URI) of the target file, and the URI of the target file specifically comprises a file information field, and the file information field is a storage path of the target file or a mapping string corresponding to the storage path.

33. The apparatus of claim 32, wherein, The URI of the target file further comprises: a device information field, which specifically comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or, an application information field, which specifically comprises a first application identifier of a first application or a mapping string corresponding to the first application identifier.

34. A file sharing apparatus, characterized by comprising: Applied to a second terminal device, the second terminal device is deployed with a second distributed file service, comprising: a data transceiving unit, configured to receive file sharing information from a first terminal device; wherein the first terminal device and the second terminal device belong to a same distributed file system, the file sharing information comprises a file identifier of a mapping file corresponding to a target file in the distributed file system, the target file is a local file stored in the first terminal device and to be shared to the second terminal device; before sending the file sharing information, the first terminal device creates metadata of the mapping file corresponding to the target file in the distributed file system, wherein the metadata of the mapping file comprises a file identifier of the mapping file and an index identifier, and an association relationship between a first file descriptor and the index identifier is established; a file opening unit, configured to open the mapping file according to the file identifier; a file descriptor passing unit, configured to generate a second file descriptor for accessing the mapping file in an open state for a second application, and provide the second file descriptor to the second application; wherein the second distributed file service is configured to receive a second file access request of the second application to the mapping file in the open state, the second file access request comprises a request parameter and the second file descriptor; send a first file access request to the first terminal device, the first file access request comprises the request parameter and the index identifier of the mapping file, the index identifier is obtained from the metadata of the mapping file according to the file identifier; the first terminal device is further configured to query the association relationship according to the index identifier, determine the first file descriptor, and access the target file in the open state according to the request parameter and the first file descriptor.

35. The apparatus of claim 34, wherein, The second distributed file service is further configured to receive a metadata synchronization message from the first terminal device; wherein the metadata synchronization message comprises the metadata of the mapping file.

36. The apparatus of claim 34, wherein the data transceiving unit is further configured to receive a file sharing request from the first terminal device; wherein the file sharing request comprises a global identifier of the target file, the global identifier is a unique identifier of the target file in the first terminal device; the data transceiving unit is further configured to provide the file sharing request to the second application; The data transceiving unit is further configured to send a file sharing response to the second terminal device in response to a triggering operation of the global identifier by the user through the second application program, wherein the file sharing response comprises the global identifier.

37. The apparatus of claim 36, wherein, The file sharing request further comprises a first application identifier of a first application, wherein the first application is deployed in the first terminal device and has an access right to the target file, and the first application identifier is a unique identifier of the first application in the first terminal device. The file sharing response further comprises the first application identifier.

38. The apparatus of claim 36, wherein, The global identifier of the target file comprises a uniform resource identifier (URI) of the target file, wherein the URI of the target file comprises a file information field, and the file information field is a storage path of the target file or a mapping string corresponding to the storage path.

39. The device of claim 38, wherein, The URI of the target file further comprises: a device information field, wherein the device information field comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or an application information field, wherein the application information field comprises a first application identifier of a first application or a mapping string corresponding to the first application identifier. The second terminal device is configured to deploy a second distributed file service, comprising:

40. A file sharing apparatus, characterized by comprising: a data transceiving unit configured to receive file sharing information from a first terminal device, wherein the first terminal device and the second terminal device belong to a same distributed file system, the file sharing information comprises a temporary identifier, the first terminal device establishes an association relationship between the temporary identifier and a target file in an open state, and the target file is a local file stored in the first terminal device and to be shared to the second terminal device; before sending the file sharing information, the first terminal device is configured to generate the temporary identifier and establish the association relationship between the temporary identifier and the target file in the open state; a file management unit configured to create a temporary file in an open state in the second terminal device; a file descriptor passing unit configured to generate a second file descriptor for accessing the temporary file in the open state for a second application, and provide the second file descriptor and the temporary identifier to the second application. ​ The second distributed file service is configured to receive a second file access request of the second application program for the temporary file in the open state, the second file access request comprising the second file descriptor, the temporary identifier and a request parameter; and send a first file access request to the first terminal device, wherein the first file access request comprises the request parameter and the temporary identifier.

41. The apparatus of claim 40, wherein, the data transceiver is further configured to receive a file sharing request from the first terminal device, wherein the file sharing request comprises a global identifier of the target file, and the global identifier is a unique identifier of the target file in the first terminal device; the data transceiver is further configured to provide the file sharing request to the second application program; the data transceiver is further configured to send a file sharing response to the second terminal device in response to a user triggering operation on the global identifier via the second application program, and wherein the file sharing response comprises the global identifier.

42. The apparatus of claim 41, wherein, the file sharing request further comprises a first application identifier of a first application program, and wherein the first application program is deployed in the first terminal device and has an access right to the target file, and the first application identifier is a unique identifier of the first application program in the first terminal device; the file sharing response further comprises the first application identifier.

43. The apparatus of claim 41, wherein, the global identifier of the target file comprises a uniform resource identifier (URI) of the target file, and wherein the URI of the target file comprises a file information field, and the file information field comprises a storage path of the target file or a mapping string corresponding to the storage path.

44. The device of claim 43, wherein, the URI of the target file further comprises: a device information field, and wherein the device information field comprises a device identifier of the first terminal device or a mapping string corresponding to the device identifier; and / or an application information field, and wherein the application information field comprises a first application identifier of the first application program or a mapping string corresponding to the first application identifier.

45. A terminal device, comprising a memory and a processor, wherein the memory stores computer program instructions / codes, and the processor executes the computer program instructions / codes to implement the method of any one of claims 1-11 or 12-22. ​ 46.A computer-readable storage medium storing computer program instructions / code that, when executed by a processor of a terminal device, cause the terminal device to implement the method of any one of claims 1-11 or claims 12-22.

Citation Information

Patent Citations

  • Communication system, server and terminal

    CN103354552A

  • Mobile terminal and file sharing method thereof

    CN106778245A

  • System and method for file sharing

    US20160219058A1