WO2014101208A1 - Method and device for obtaining file - Google Patents

Method and device for obtaining file Download PDF

Info

Publication number
WO2014101208A1
WO2014101208A1 PCT/CN2012/088091 CN2012088091W WO2014101208A1 WO 2014101208 A1 WO2014101208 A1 WO 2014101208A1 CN 2012088091 W CN2012088091 W CN 2012088091W WO 2014101208 A1 WO2014101208 A1 WO 2014101208A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
application
source
filesystem
path
Prior art date
Application number
PCT/CN2012/088091
Other languages
French (fr)
Chinese (zh)
Inventor
王嗣琛
周皓隽
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201280003352.1A priority Critical patent/CN104137073B/en
Priority to PCT/CN2012/088091 priority patent/WO2014101208A1/en
Publication of WO2014101208A1 publication Critical patent/WO2014101208A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method and apparatus for acquiring a file.
  • a web application is an application that causes a browser to execute commands or actions required by the web application by invoking a web application programming interface (API).
  • API web application programming interface
  • the web API is a call interface that the browser opens to the web application.
  • the browser provides a set of APIs for the file system filesystem in the API that is open to the application.
  • Applications can be obtained by calling the filesystem API interfaces, application data is written f ilesystem 0 f ilesysem is a sandbox sandbox mechanism-based file system, the source (origin) to determine the unit who follow the principles of preservation who acquired from different sources can not be applied Get the other party's data.
  • the application invokes the filesystem API interface to instruct the browser to allocate a file system storage space of a certain size, which is used to save the application data, and to read and write files and directories in the application-defined filesystem.
  • the origin is a subset of the URL, and each web application has a URL.
  • the source consists of the scheme part, the host part, and the port part of the application's URL. Due to different rules (3 ⁇ 4. hUps and hup), the source of the hups: ⁇ www. hello, com page and http: //www. hello, com page are different. The concept of the source does not take into account the path, such as http: //www.hel lo. com/ index, html and hup: //www.hel lo. com/ ages, html has the same source.
  • the following sources are different sources:
  • Http / / example, com/ Http: / / example, com: 8080/
  • Http //www. example, com/
  • Http //example, org/
  • Http / / example, com/
  • Http / / example, com: 80/
  • Http / / example, com/ ath/ file
  • the file automatically saved by the browser is directly saved by the browser to the filesystem on the user device, and only the browser can directly operate (such as modifying, reading, etc.) the previously saved file.
  • the filesystem is a file system based on the s andbox mechanism
  • the file automatically saved by the application through the browser can only be obtained by the application with the same application as the application, and the application different from the application cannot obtain the file.
  • the file, that is, the source A web application cannot obtain the file of the source B application saved in the filesystem.
  • Embodiments of the present invention provide a method and an apparatus for acquiring a file, so as to obtain a file across a source in a filesystem.
  • the method for obtaining a file is applied to a file system filesystem based on a sandbox sandbox mechanism, and the method includes:
  • the method further includes:
  • the creation source is a source of the first application that saves the file, and receiving an authorization source of the file specified by the first application, where the authorization source is authorized to obtain the Source of the file;
  • the acquiring the file from the file system of the first application according to the path of the file Providing to the second application specifically includes:
  • a file is provided to the second application.
  • the receiving is different from the first application
  • the instructions for acquiring the file triggered by the second application include:
  • the method further includes:
  • the path of the file is carried in a cross-document communication message postMessage sent by the first application to the second application, or And carried in the Hypertext Transfer Protocol (HTTP) message sent by the first application to the second application.
  • HTTP Hypertext Transfer Protocol
  • the method further includes:
  • the browser receives a file acquisition request initiated by the second application by using the file API, where the file acquisition request instructs the browser to acquire the file by using a manner selected by the user;
  • the browser opens a file selection interface according to the file acquisition request, and displays an optional file in the filesystem in the file selection interface;
  • the instruction for acquiring the file triggered by the second application receiving the different source of the first application comprises: receiving an instruction of the user to select the file in the file selection interface.
  • the displaying, in the file selection interface, the optional file in the filesystem includes:
  • the browser determines an optional file in the filesystem that can be obtained by the second application, generates an associated virtual file for each optional file, and uses the path of the optional file as the information associated with the virtual file, and The generated virtual file is presented in the file selection interface such that the user selects a file associated with the virtual file through the virtual file.
  • an eighth possible implementation before the optional file in the filesystem is displayed in the file selection interface, : generating a filesystem virtual folder, and displaying the filesystem virtual folder as a system disk in the file selection interface, and executing the file selection interface after receiving an operation of the user selecting the filesystem virtual folder The operation of displaying optional files in filesystem.
  • the method further includes: determining a creation source of the optional file, and respectively generating a virtual folder of each creation source;
  • the virtual file being displayed in the file selection interface specifically includes: using the virtual folder of the creation source as a subfolder in the filesystem virtual folder, and placing the virtual file of the optional file in a corresponding In the virtual folder of the creation source, the subfiles in the virtual folder as the creation source are presented.
  • the browser determines that the optional file that can be obtained by the second application in the filesystem specifically includes:
  • a file that creates a source including the source of the second application, and a file whose source of authorization includes the source of the second application is determined to be an optional file in the filesystem that is obtainable by the second application.
  • a device for acquiring a file is applied to a file system filesystem based on a sandbox sandbox mechanism, the device comprising:
  • An interface unit configured to provide a first file system application programming interface filesystem API
  • a request processing unit configured to receive a file save request initiated by the first filesystem API provided by the first application by the interface unit
  • a saving unit configured to save the file to be saved by the first application to the file system f i 1 e s y s t em according to the file save request received by the request processing unit;
  • An event processing unit configured to receive an instruction for acquiring a file saved by the first application triggered by a second application that is different from the first application, where the instruction carries a path of the file;
  • An obtaining unit configured to acquire a path of the file from an instruction received by the event processing unit, and obtain the file from the filesystem according to a path of the file;
  • a providing unit configured to provide the file acquired by the acquiring unit to the second application.
  • the request processing unit is further configured to receive an authorization source of the file specified by the first application, where the authorization source is authorized to obtain Take the source of the file;
  • the saving unit is further configured to record a creation source of the file and an authorization source of the file, where the creation source is a source of a first application that saves the file, and the authorization source includes the second application. Source.
  • the acquiring unit specifically includes:
  • Obtaining a subunit configured to acquire a path of the file from an instruction received by the event processing unit;
  • a searching subunit configured to search for the file in the f i lesys according to the path obtained by the obtaining subunit
  • An authentication subunit configured to: after the searching subunit finds the file, match a source of the second application with a creation source and an authorization source of the file, and determine a source of the second application.
  • the providing unit is notified to send the file found by the searching module to the second application.
  • the interface unit is further configured to provide the second fi Lesys tem API interface
  • the event processing unit receives, by using the second terminal API provided by the interface unit, the calling instruction that is triggered by the second application to acquire the file.
  • the device further includes:
  • a forwarding unit configured to receive a path of the file sent by the first application to the second application after saving the file, and forward a path of the file to the second application, so that the The second application initiates the call instruction according to the path of the file.
  • the path of the file carries a cross-document communication message sent by the first application to the second application In the pos tMes sage, or in the Hypertext Transfer Protocol HTTP message sent by the first application to the second application.
  • the interface unit is further configured to provide a f i le API
  • the event processing unit specifically includes:
  • a receiving subunit configured to receive a file obtaining request initiated by the second application through the interface provided by the interface unit, where the file obtaining request indicates that the file is obtained by using a mode selected by the user;
  • An interaction subunit configured to open a file selection interface according to the file acquisition request received by the receiving subunit, and display an optional file in the file in the file selection interface, and receive the user in the file selection interface, An instruction to select a file saved by the first application.
  • the interaction sub-unit specifically includes:
  • An interface module configured to open a file selection interface according to a file acquisition request received by the receiving subunit
  • a content module configured to determine an optional file in the system that can be obtained by the second application
  • a generating module configured to generate an associated virtual file for each optional file determined by the content module, to select the The path of the file as the information associated with the virtual file
  • a presentation module configured to display the virtual file generated by the generation module in a file selection interface opened by the interface module, so that the user selects a file associated with the virtual file by using the virtual file;
  • an event module configured to receive an instruction that the user selects a file saved by the first application in the file selection interface.
  • the generating module is further configured to generate a virtual folder;
  • the presentation module is further configured to display the filesystem virtual folder generated by the generating submodule as a system disk in the file selection interface;
  • the event module is further configured to receive an operation of the user selecting the filesystem virtual folder, and after receiving the operation, instructing the presentation module to perform the displaying the optional file in the filesystem in the file selection interface. operating.
  • the content module is further configured to determine a source of creation of the optional file
  • the generating module is further configured to separately generate a virtual folder of each creation source determined by the content module;
  • the presentation module specifically includes:
  • a first presentation submodule configured to display the filesystem virtual folder generated by the generating module as a system disk in the file selection interface
  • a second presentation submodule configured to display the virtual folder of the creation source generated by the generation module as a subfolder in the filesystem virtual folder;
  • a third presentation submodule configured to place the virtual file of the optional file generated by the generation module in a virtual folder of the corresponding creation source, as a subfile presentation in the virtual folder of the creation source.
  • the optional file that can be obtained by the second application in the filesystem includes: a file whose creation source includes the source of the second application, and a file whose source of authorization includes the source of the second application.
  • the path of the file saved by the application of different sources may be provided to the browser in the file system filesystem based on the sandbox mechanism, thereby realizing the cross-source file acquisition.
  • FIG. 1 is a flowchart of a method for acquiring a file according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for obtaining a file according to another embodiment of the present invention.
  • FIG. 3 is a flowchart of a method for obtaining a file according to another embodiment of the present invention.
  • FIG. 4 is a flowchart of a method for acquiring a file in an application scenario according to an embodiment of the present invention
  • FIG. 5 is a flowchart of another embodiment of a method for acquiring a file in an application scenario
  • FIG. 6 is a schematic diagram of an interface of a virtual folder of a virtual thread according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram of a display interface of a virtual folder for creating a source according to an embodiment of the present invention
  • FIG. 8 is a schematic diagram of providing a virtual file according to an embodiment of the present invention
  • Interface diagram ;
  • FIG. 9 is a schematic structural diagram of an apparatus for acquiring a file according to an embodiment of the present invention
  • FIG. 10 is a schematic structural diagram of an apparatus for acquiring a file according to another embodiment of the present invention
  • FIG. 12 is a schematic structural diagram of a device for acquiring a file according to an embodiment of the present invention
  • FIG. 13 is a schematic diagram of a hardware structure of an apparatus for acquiring a file according to an embodiment of the present invention.
  • the source in the embodiment of the present invention includes a rule part in the Uniform Resource Locator URL of the application, Host part and port part.
  • FIG. 1 is a flowchart of a method for acquiring a file according to an embodiment of the present invention.
  • the method can be applied to a file system filesystem based on a sandbox sandbox mechanism.
  • the method for obtaining a file in this embodiment includes:
  • the browser receives a file save request initiated by the first application through the first file system application programming interface filesystem API provided by the browser.
  • the first application is an application running in a browser, such as a web application.
  • the first file system application programming interface filesystem API can include at least one filesystem API.
  • the first application can initiate a file save request by calling the getFile API and the Write API in the filesystem API.
  • getFi le is used to get the file entry
  • Write is used to write the data to be saved to the file. That is, the first application first obtains the filesystem file, and then writes the data to be saved in the file.
  • Obtaining a file can be:
  • DOMString path is the file path.
  • the application saved by the originating file specifies the path to save the file and uses that path as the file identifier to uniquely identify the file. For example, getFile ( "/BenPicture/Ben. jpg", ⁇ create: true ⁇ ); where " /BenPicture/Ben. jpg " can be considered as the identifier of the file, which can be obtained by "/BenPicture/Ben. jpg"
  • the entry to the file to save. ⁇ create: true ⁇ means that if the file does not exist, it is created.
  • the reques tFi leSystem API in the filesystem API may be invoked to instruct the browser to allocate a file system storage space of a certain size for saving the file of the first application.
  • the browser finds the file specified by "DOMString path" in the getFile in the filesystem, and writes the data to be saved by the first application into the file, and the file after the data is written is the file saved by the first application. . If the file specified by "DOMString path" does not exist in filesystem, create the file and write the data to be saved to the file.
  • S104 Receive an instruction for acquiring the file triggered by a second application that is different from the first application, where the instruction carries a path of the file.
  • the second application is an application that runs in a browser.
  • the source of the second application is known by the URL of the second application.
  • the instruction may also carry the identifier.
  • the browser can obtain the path of the file from the received instruction.
  • the browser obtains the file from the filesystem specified by the filesystem identifier.
  • the path of the file saved by the application of different sources may be provided to the browser in the file system filesystem based on the sandbox mechanism, thereby realizing the cross-source file acquisition.
  • the browser when the second application acquires the file saved by the first application in the filesystem, the browser can be notified in the following two ways:
  • the second application may invoke a second filesystem API provided by the browser to instruct the browser to obtain the file from the filesystem of the first application, and specify the path of the file to be obtained when the filesystem API is called.
  • the instruction for acquiring the file triggered by the second application that is different from the first application in the step 104 may include: receiving the second application to invoke the browser.
  • the second filesystem API is to obtain a call instruction of the file saved by the first application.
  • the path information provided by the second application to the browser may be sent by the first application to the second application after saving the file.
  • FIG. 2 is a flowchart of a method for instructing a browser to acquire a file, as shown in FIG. 2, the method includes:
  • the browser receives a file save request initiated by the first application through the first file system application programming interface filesystem API provided by the browser.
  • the first application may send the storage information of the file to the second application by using the cross-document communication message postMessage, and instruct the second application to obtain the file from the filesystem.
  • the message format of postMessage is as follows:
  • f ilesystemRetrieve DOMString path
  • f ilesystemRetrieve means ":” after the "DOMString path” indicates that the file is to be fetched from filesystem; after the colon “DOMString path” is the file in fi lesys tem
  • the save path which can be used as an identifier for the file, is used to uniquely identify and locate the file in the filesystem; "The URL of the second application" is the message destination field.
  • the first application may further send the storage information of the file to the second application by using a Hypertext Transfer Protocol (HTTP).
  • HTTP Hypertext Transfer Protocol
  • the "file path" and "f ilesystemRetrieve" identifiers are added to the GET message sent by the first application to the second application, and the specific format is as follows:
  • S206 Receive a second application that invokes a second filesystem API provided by the browser to obtain a call instruction of the file saved by the first application.
  • the second application After receiving the file storage information sent by the first application, the second application knows that the file needs to be obtained from the filesystem. Therefore, the second function provided by the browser is used to obtain the file, and the file is carried in the calling instruction. path.
  • the second filesystem API may include at least one filesystem API, and may include a filesystem API in the first filesystem API.
  • the second application may invoke the getfile API and the FileReaderAPI to instruct the browser to obtain the file.
  • getFile is used to get the file entry
  • FileReader is used to read the data from the file found by getFile.
  • the second application carries the path of the file received from the first application in getFile, for example, getFile ("DOMString path").
  • the foregoing embodiment sends the path of the file saved by the first application in the file system to the second application by extending the interaction message between the first application and the second application, so that the second application can obtain the first application by using the path.
  • Files in filesystem for cross-source access
  • the embodiment of the present invention may further allow the first application to specify the authorization source, and the other source may obtain the saved by the first application only in the authorization source specified by the first application. file.
  • the method further includes: recording a creation source of the file, where the creation source is a source of the first application that saves the file, and receiving an authorization source of the file specified by the first application, where The authorization source is a source that is authorized to obtain the file; an authorization source of the file is recorded, and an authorization source of the file includes a source of the second application.
  • the browser can extend the following filesystem API to enable the first application to specify 4 authorized sources through the following filesystem API, such as:
  • the browser can extend the getFile API so that the first application can specify the authorization source in the file save request of S202 using the API provided by the browser.
  • the browser can extend the getFile API so that the first application can specify the authorization source in the file save request of S202 using the API provided by the browser.
  • DOMString path is a file path, which is used to uniquely identify the file in filesystem
  • DOMString Pemiss ions is a new field, indicating 4 authorized sources. For example: getFile ( “/BenPicture/Ben. jpg", ⁇ create: ture ⁇ , "*. drawing, com” ), then the picture /BenPicture/Ben. jpg can be obtained from the source of *. drawing, com.
  • the browser can extend the requestFileSystem API, so that the first application uses the API provided by the browser to specify the authorization source when obtaining the filesystem space. All files in the ilesystem space take effect. mouth:
  • the c browser can extend a new API so that the first application uses the browser to provide this new API to specify the file authorization source.
  • a new API such as:
  • createFilePermissions (DOMString path, DOMString Pemissions); where createFilePermissions is the new API, "DOMString path” is the file path, which is used to uniquely identify the files in the fleetsystem, and "DOMString Pemissions" is the authorization source.
  • one or more authorization sources can be specified, and the browser can create a relationship table to record the relationship between the file and the creation source and the authorization source, as shown in Table 1:
  • the obtaining, according to the path of the file, the file is obtained from the file system of the first application
  • the providing the file to the second application may include: searching for the file in the filesyetem according to the path of the file. After finding the file, matching the source of the second application with the creation source of the file and the authorization source, and providing the file when determining that the source of the second application is the authorization source of the file Give the second application.
  • the browser may first determine whether the source of the request (ie, the source of the second application) is the same as the source of the creation. If the source is different, and then determine whether the source is the authorized source, the two may simultaneously determine the specific judgment sequence.
  • the embodiment of the invention is not limited.
  • the field "DOMString Pemissions" for specifying the authorization source can be expressed as "permission: authorization source”.
  • the permissions can be: Access: can operate files, such as uploading servers, modifying, etc.
  • Read can only read files
  • getFile Take the extended getFile as an example.
  • getFile "/BenPicture/Ben. jpg", “read: *. drawing, com” ); indicating *. drawing, com can get the file /BenPicture/ Ben. jpg, but only the file can be read and cannot be modified.
  • the embodiment of the present invention increases the security in the cross-source access process by specifying an authorization source for the file so that only the application of the authorization source can obtain the file.
  • the instruction for acquiring the file triggered by the second application receiving the different source of the first application in step 104 includes: receiving the user in the file selection interface, selecting The instructions of the file.
  • the specific processing flow can be seen in Figure 3.
  • FIG. 3 is a flowchart of a method for instructing a browser to acquire a file by using the second method, the method includes:
  • the browser receives a file save request initiated by the first application through the first file system application programming interface filesystem API provided by the browser.
  • S304 The browser receives a file acquisition request initiated by the second application by using the file API, where the file acquisition request instructs the browser to obtain the file by using a manner selected by the user;
  • the browser opens the file selection interface according to the file acquisition request, and displays an optional file in the filesystem in the file selection interface.
  • the file in filesystem is displayed in the file selection interface for the user to select.
  • the file selection interface is displayed.
  • S308. Receive an instruction that the user selects a file saved by the first application in the file selection interface.
  • the user can select a file in the file selection interface by clicking and the like.
  • the browser can receive the selected instruction triggered by the operation, and indicate by the path carrying the file in the instruction.
  • the files are only visible to the browser.
  • the files that the user sees through the file selection interface are not in a single file format, so the user cannot select files through the file selection interface.
  • the browser can present the files in the filesystem to the user selection in the form of virtual files.
  • the displaying the optional file in the filesystem in the file selection interface in the step 306 includes: the browser determining an optional file in the filesystem that can be obtained by the second application, and generating an associated virtual file for each optional file, Taking the path of the optional file as information associated with the virtual file, and presenting the generated virtual file in a file selection interface, so that the user selects a file associated with the virtual file through the virtual file.
  • the browser attaches the path of the file to the virtual file when the virtual file is generated, to associate the virtual file with the corresponding optional file.
  • a virtual file is generated for each optional file and displayed to the user, so that the user selects a virtual file to be associated with a separate single file, thereby implementing the user in the filesystem of the large file storage mode.
  • an optional file that can be obtained by the second application in the filesystem may be all files in the filesystem.
  • the first application may be allowed to specify an authorization source, and other sources may acquire the file saved by the first application only in the authorization source specified by the first application.
  • Filesystem The optional file obtained by the second application may only include files that are authorized to be obtained.
  • the method further includes: recording a creation source of the file, where the creation source is a source of the first application that saves the file; and receiving an authorization source of the file specified by the first application, where The authorization source is a source that is authorized to obtain the file; an authorization source of the file is recorded, and an authorization source of the file includes a source of the second application.
  • the manner in which the first application specifies the authorization source refer to the embodiment shown in FIG. 2.
  • the manner in which the browser records the creation source and the authorization source may also refer to Table 1 in the embodiment shown in FIG. 2, and details are not described herein again.
  • the browser determines that the optional file that can be obtained by the second application in the filesystem comprises: a file that creates a source including the source of the second application, and a file whose source of authorization includes the source of the second application is determined as An optional file in the filesystem that can be obtained by the second application.
  • the embodiment of the present invention can also perform hierarchical presentation in the file selection interface. Specifically, before the optional file is displayed in the file selection interface, the method further includes: generating a filesystem virtual folder, and displaying the virtual thread virtual folder as a system disk in the file selection interface, and receiving the filesystem virtual The operation of presenting the optional file in the file selection interface is performed after the operation of the folder.
  • the browser can display the filesystem virtual folder as a system disk together with the C disk, the D disk, and the like.
  • the executable file that can be obtained by the second application in the filesystem is determined. And generate a corresponding virtual file, and the generated virtual file is displayed as a subfile in the fi 1 esyst em virtual folder.
  • the embodiment of the present invention can not only display the filesystem virtual folder layer, but also display multiple layers such as creating a source layer and creating a source host layer.
  • the browser further includes: determining the creation source of the optional file, and respectively generating the virtual folder of each creation source.
  • the displaying the generated virtual file in the file selection interface specifically includes: creating a virtual folder of the source as a subfolder in the filesystem virtual folder, and placing the virtual file of the optional file in the virtual of the corresponding creation source. In the folder, as a subfile of the creation source virtual folder. Need to say It is to be noted that, in this embodiment, the creation source corresponding to the file needs to be recorded in advance, and specifically, the creation source of the file may be recorded when the browser saves the file in step 302.
  • the application scenario is as follows: The user takes a photo on the photo website hUp: ⁇ w. paizhao. com/ uses the camera application, wants to use the professional website for processing photos hup: //www. drawing, drawing application in com/ To post-process this photo.
  • the first application is camera, the source is http: //www. paizhao.com/, the second application is drawing, and the source is http: //www. drawing.com/.
  • FIG. 4 is a flowchart of a method for instructing a browser to acquire a file in an application scenario. As shown in FIG. 4, the method includes:
  • the camera application running in the browser uses a file save request initiated by the first filesystem API provided by the browser, and specifies an authorization source in the file save request.
  • the browser runs the camera application, and uses the camera function of the camera application to realize the photographing.
  • the camera application calls the following filesystem API provided by the browser: f s. getFi le ( "/ camera /Mike' s head, jpg” , ⁇ create: ture ⁇ , " *. drawing, com” Initiating a file save request to the browser, where "/camera/Mike's head, jpg” is the save path specified for the camera application, and as an identifier that uniquely identifies the file, "*. drawing, com” is the 4 authorized source , "*” is a wildcard that can represent one or more characters.
  • Fs is the identifier of the camera application f i lesys tem.
  • the browser saves the file to be saved by the camera application to the file system according to the file save request, and records the creation source and the authorized source of the file.
  • the camera application can first apply for the filesystem space in the fi lesys by reques tf i lesys, in order to save the file to be saved to its own filesystem.
  • the browser obtains a file in the camera's system based on "/camera/Mike's head, jpg". If there is no such file, the file is created in the camera's fi lesys, and the photo data is saved. Go to the file obtained.
  • the camera application sends a request to the browser to the drawing application, and sends the file save path to the drawing application through the browser.
  • the user can click the "to draw application to edit" button displayed on the camera application page, that is, initiate a request directed to the drawing application, and carry the file path of the saved photo in the request.
  • “/camera/Mike's head” is the path to the file in the fleetsystem.
  • the browser opens an if rame or tab or a new window based on the request, loads the page of the www. drawing, com website, and passes the path of the saved photo to the drawing application on the page.
  • This embodiment is described by taking an example from the camera application orientation to the drawing application.
  • the drawing application is opened by the user himself.
  • the camera application sends the file path to the drawing application via the cross-document communication message postMessage, and instructs the drawing application to retrieve the file data from the user's local filesystem.
  • hup //www. drawing, com”
  • the drawing application determines, according to the received file path, that the file is obtained from the filesystem, and then calls the filesystem API provided by the browser to obtain the file saved by the camera application, and uses the file path obtained from the camera application as the called API. parameter.
  • the drawing application calls the filesystem API to send a call instruction to the browser. For example: fi lesys temname. getFi le ( "/ camera /Mike' s head, jpg” ).
  • the browser determines whether the request source is a file creation source or an authorization source. If the source or the authorization source is created, executing S412 to provide the file to the drawing application; if neither the creation source nor the authorization source, executing S414, returning Get the failure response.
  • the request source is the source corresponding to the application requesting to obtain the file.
  • the browser finds the pre-recorded creation source and the 4 authorized source according to the file path "/camera /Mike' s head, jpg" in the file system space specified by fi lesys temname, and determines that the file is created with the source "http: //www . paizhao. com/” , the authorized source is drawing. com, '.
  • the source of the drawing application requesting the file is "hup: //www. drawing.com ⁇ ", and therefore, step S412 is performed.
  • FIG. 5 is a flowchart of a method for instructing a browser to acquire a file in the application scenario. As shown in FIG. 5, the method includes:
  • the camera application running in the browser sends a file save request initiated by the first filesystem API provided by the browser, and specifies an authorization source in the file save request.
  • the browser saves the file to be saved by the camera application to the file system according to the file save request, and records the creation source and the authorized source of the file.
  • the input here is not only a keyboard typing input, but a generalized concept, which can be a user input method such as clicking a file.
  • FIG. 6 is a schematic diagram of a display interface of a filesystem virtual folder, wherein the "web source" folder is a filesystem virtual folder,
  • the browser receives an operation of selecting a filesystem virtual folder in a file selection interface.
  • the browser After the user clicks the filesystem virtual folder in the file selection interface, the browser receives the user's selection operation.
  • the browser determines an optional file in the filesystem that can be obtained by the second application, and a creation source of the optional file, and generates a creation source folder and a virtual file associated with the optional file, and the virtual file of the source is created.
  • the folder is a subfolder in the filesystem virtual folder, and the virtual file of the optional file is placed in the virtual folder of the corresponding creation source, and is displayed as a subfile of the creation source virtual folder.
  • the browser can determine the optional file that can be obtained by the second application and the creation source of the optional file according to the creation source and the authorization source of the pre-recorded file. Specifically, the browser can traverse each file in the filesyste to determine whether the source of the drawing application is in the creation source or the authorization source of the file, thereby determining the available file and the creation source of the file.
  • FIG. 7 is a schematic diagram of the display interface of the virtual folder for creating the source.
  • Figure 8 is a schematic diagram of the virtual file display interface.
  • the browser may first display the virtual folder of the creation source, and when receiving the operation of selecting the virtual folder of the source, the virtual file is generated and displayed.
  • S518 Receive an operation of selecting a virtual file corresponding to a file saved by the camera application.
  • the operation sends the associated information of the virtual file to the browser.
  • the browser can obtain the corresponding file according to the associated information of the virtual file (ie, the file path).
  • the application can obtain storage information of applications of different sources, for example, The file path overcomes the problem that the files saved by different source applications are invisible to each other in the file system filesystem based on the sandbox mechanism, and the cross-source file acquisition is realized.
  • FIG. 9 is a schematic diagram showing an exemplary logical structure of an apparatus for acquiring a file according to an embodiment of the present invention.
  • the device is applied to a file system based on the sandbox sandbox mechanism.
  • the apparatus includes: an interface unit 901, a request processing unit 902, a saving unit 903, an event processing unit 904, an obtaining unit 905, and a providing unit 906.
  • the interface unit 901 is configured to provide a first file system application programming interface filesystem API.
  • the first file system application programming interface filesystem API may include at least one filesystem API, such as a getFile API and a Write API.
  • a request processing unit 902 configured to receive a first application provided by the interface unit 901
  • the request processing unit 902 can obtain the file entry through the getFile API, and write the data to be saved to the acquired file through the Wr i te API.
  • the request processing unit 902 can obtain the file entry through the getFile API, and write the data to be saved to the acquired file through the Wr i te API.
  • the first application may also invoke the reques tFi leSystem API in the filesystem API to instruct the browser when initiating the file save request.
  • a file system storage space of a certain size is allocated for storing the file of the first application.
  • the first application may initiate a request to allocate filesystem storage space by request processing unit 902.
  • the saving unit 903 is configured to save the file to be saved by the first application to the file system f i 1 e s y s t em according to the file saving request received by the request processing unit 902.
  • the saving unit 903 finds the file specified by the "DOMString path" in the getFile in the filesystem, and writes the data to be saved by the first application into the file, and the file after the data is written is saved by the first application. file. If the file specified by "DOMString path" does not exist in the filesystem, create the file and write the data to be saved to the file.
  • the event processing unit 904 is configured to receive an instruction for acquiring a file saved by the first application triggered by a second application that is different from the first application, where the instruction carries a path of the file.
  • An obtaining unit 905, configured to acquire a path of the file from an instruction received by the event processing unit 904, and obtain the file from the filesystem according to a path of the file;
  • a providing unit 906, configured to: The file acquired by the obtaining unit 905 is provided to the second application.
  • the event processing unit 904 can obtain an instruction of the file saved by the first application triggered by the second application received by the following two methods:
  • Manner 1 Receive an instruction of the second application to obtain the file by calling a second filesystem API.
  • the interface unit 901 is further configured to provide a second filesystem API; the event processing unit 904 receives the second application-triggered call instruction for acquiring the file through the second filesystem API provided by the interface unit 901.
  • Manner 2 The receiving user selects an instruction of the file saved by the first application in the file selection interface.
  • the interface unit 901 is further configured to provide a file API;
  • the event processing unit 904 is further configured to receive a file acquisition request initiated by the second application through the file API provided by the interface unit 901, where the file acquisition request indicates that the user selects Way to get the file.
  • the event processing unit 904 opens a file selection interface according to the file acquisition request, and displays an optional file in the filesystem in the file selection interface, so that the user selects the file saved by the first application in the file selection interface.
  • the apparatus for acquiring a file may further include a forwarding unit 1001. As shown in FIG. 10, FIG. 10 is an exemplary embodiment of an apparatus for acquiring a file according to another embodiment of the present invention. Schematic diagram of the logical structure.
  • the forwarding unit 1001 is configured to receive a path of the file that is sent by the first application to the second application after saving the file, and forward the path of the file to the second application, so that the second The application initiates a call instruction to invoke the second filesystem API according to the path of the file.
  • the path of the file may be carried in the cross-document communication message postMessage sent by the first application to the second application, or may be carried in the Hypertext Transfer Protocol (HTTP) message sent by the first application to the second application.
  • HTTP Hypertext Transfer Protocol
  • the interface unit 901 is also used to provide a second filesystem API.
  • the event processing unit 904 receives the second application-triggered call instruction for acquiring the file through the second filesystem API provided by the interface unit 901.
  • the request processing unit 902 is further configured to receive an authorization source of the file specified by the first application, where the authorization source is a source that is authorized to obtain the file. See the method embodiment section shown in Figure 2 for specific implementation.
  • the saving unit 903 is further configured to record a creation source of the file and an authorization source of the file, where the creation source is a source of the first application that saves the file, and the authorization source includes the second application. source.
  • the creation source is a source of the first application that saves the file
  • the authorization source includes the second application. source.
  • the obtaining unit 905 specifically includes:
  • the obtaining subunit 1002 is configured to obtain a path of the file from an instruction received by the event processing unit 904;
  • the finding subunit 1003 is configured to search for the file in the filesystem according to the path obtained by the obtaining subunit 1002.
  • the authentication subunit 1004 is configured to: after the searching subunit 1003 finds the file, match the source of the second application with the creation source and the authorization source of the file, and determine the source of the second application as the source When the authorization source of the file is described, the notification providing unit 906 sends the file found by the searching module 1003 to the second application.
  • the above embodiment sends the path of the file saved in the filesystem to the second application, so that the second application can obtain the first application by using the path.
  • Files in filesystem for cross-source access and by specifying an authorization source for the file, the application can be obtained only by the application of the authorization source, which increases the security in the process of cross-origin access.
  • the interface unit 901 is further configured to provide a file API.
  • the event processing unit 904 may specifically include a receiving subunit 1101 and an interaction subunit. 1102.
  • FIG. 11 is a schematic diagram showing an exemplary logical structure of an apparatus for acquiring a file according to another embodiment of the present invention.
  • the receiving subunit 1101 is configured to receive a file acquiring request initiated by the file API provided by the second application by the interface unit 901, where the file obtaining request indicates that the file is obtained by using a mode selected by the user;
  • the interaction sub-unit 1102 is configured to open a file selection interface according to the file acquisition request received by the receiving sub-unit 1101, display an optional file in the filesystem in the file selection interface, and receive the user in the file selection interface, select the first An instruction to apply a saved file.
  • a virtual file is generated for each optional file and displayed to the user, so that the user selects a virtual file to be associated with a separate single file, thereby implementing the user in the filesystem of the large file storage mode.
  • an optional file that can be obtained by the second application in the filesystem may be all files in the filesystem.
  • the request processing unit 902 is further configured to receive an authorization source of the file specified by the first application, where the authorization source is a source that is authorized to obtain the file.
  • the saving unit 903 is further configured to record a creation source of the file and an authorization source of the file, where the creation source is a source of a first application that saves the file, and the authorization source includes the second application The source used.
  • the creation source is a source of a first application that saves the file
  • the authorization source includes the second application The source used.
  • the embodiment of the present invention increases the security in the cross-source access process by specifying an authorization source for the file so that only the application of the authorization source can obtain the file.
  • the interaction subunit 1102 may specifically include:
  • the interface module 11021 is configured to open a file selection interface according to the file obtaining request received by the receiving subunit 1101;
  • a content module 11022 configured to determine an optional file in the filesystem that is obtainable by the second application
  • the generating module 11023 is configured to generate an associated virtual file for each optional file determined by the content module 11022, and use the path of the optional file as information associated with the virtual file, and the presentation module 11024 is configured to generate The virtual file generated by the module 11023 is displayed in a file selection interface opened by the interface module 11021, so that the user selects a file associated with the virtual file through the virtual file;
  • the event module 11025 is configured to receive an instruction that the user selects a file saved by the first application in the file selection interface.
  • the generating module 11023 is further configured to generate a filesystem virtual folder
  • the presentation module 11024 is further configured to display the filesystem virtual folder generated by the generating submodule 11023 as a system disk in the file selection interface;
  • the event module 11025 is further configured to receive an operation of the user selecting the filesystem virtual folder, and after receiving the operation, the presentation module 11024 performs an operation of displaying an optional file in the filesystem in the file selection interface.
  • a multi-level presentation can also be implemented in the file selection interface, for example, a plurality of layers such as a source layer and a source host layer can be displayed.
  • the content creation module 11022 is further used to determine the optional file. Source of creation;
  • the generating module 11023 is further configured to separately generate a virtual folder of each creation source determined by the content module 11022;
  • the presentation module 11024 specifically includes:
  • a first presentation sub-module 110241 configured to display the filesystem virtual folder generated by the generating module 11023 as a system disk in the file selection interface
  • a second presentation sub-module 110242 configured to display the virtual folder of the creation source generated by the generation module 11023 as a sub-folder in the virtual folder of the f i 1 e s y s t em;
  • a third presentation sub-module 110243 configured to place the virtual file of the optional file generated by the generating module 11023 in a virtual folder of a corresponding creation source, as a sub-file in the virtual folder of the creation source Show.
  • the creation source corresponding to the file needs to be recorded in advance, and the storage unit 903 can record the creation source of the file when the file is saved.
  • the device described in FIG. 9, FIG. 10 and FIG. 11 may be a device including a browser and including a hardware structure required to run the browser, and the device may include a computer, a tablet, and a personal digital assistant (PDA). ), mobile terminal, etc.
  • Figure 12 is a hierarchical structure diagram of the apparatus.
  • the device includes an application 1201, a browser 1202, an operating system 1203, and hardware 1204.
  • the application 1201 is an application running in the browser 1202, and uses an API opened by the browser 1202 to acquire the open service or device capability of the browser 1202, and provides various services for the user; the application may be web-based, and browsed. To run, it is the product of the browser/server (ie B/S) architecture, and each application has a corresponding URL.
  • B/S browser/server
  • the browser 1202 is configured to communicate with an operating system and obtain an API provided by an operating system. The ability to get the underlying hardware; and provide an environment for the application 1201 running in the browser 1202; operating system: including a hardware driver, communicating with the hardware, receiving and processing input signals generated by the hardware;
  • Hardware can include, for example, a processor, a memory, a communication interface, and the like.
  • the apparatus may include a processor 1301, a memory 1302, a communication interface 1303, and a bus 1304.
  • the processor 1301, the memory 1302, and the communication interface 1303 are communicably connected by a bus 1304.
  • the processor 1301 can use a general-purpose central processing unit (CPU), a processor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs,
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • the technical solution provided by the embodiment of the present invention is implemented, wherein the browser can be run in the processor 1301 to implement the functions described in the foregoing method embodiments and device embodiments.
  • the memory 1302 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
  • the memory 1302 can store an operating system and other applications.
  • the program code for implementing the technical solution provided by the embodiment of the present invention such as an application of a browser, is stored in the memory 1302, and is processed by the processor 1301. To execute.
  • the communication interface 1303 implements the device with other devices or communication networks using, for example, but not limited to, transceivers such as transceivers (such as, but not limited to, Ethernet, Radio Access Network (RAN), Wireless Local Area Network (Wireless Local). Communication between Area Network, WLAN, etc.).
  • transceivers such as, but not limited to, Ethernet, Radio Access Network (RAN), Wireless Local Area Network (Wireless Local). Communication between Area Network, WLAN, etc.).
  • Bus 1304 can include a path for communicating information between various components of the device, such as processor 1301, memory 1302, and communication interface 1303.
  • FIG. 13 only shows the processor 1301, the memory 1302, the communication interface 1303, and the bus 1304, in a specific implementation process, those skilled in the art It should be understood that the device also includes other components necessary to achieve normal operation. At the same time, those skilled in the art will appreciate that hardware devices that implement other functions may also be included, depending on the particular needs.
  • Computer readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another.
  • a storage medium may be any available media that can be accessed by a computer.
  • computer readable media may comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage media or other magnetic storage device, or can be used for carrying or storing in the form of an instruction or data structure.
  • the desired program code and any other medium that can be accessed by the computer may suitably be a computer readable medium.
  • the software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable , fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, wireless, and microwaves are included in the fixing of the associated media.
  • coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, wireless, and microwaves are included in the fixing of the associated media.
  • a disc (Di sk ) and a disc (di sc ) include a compact disc (CD), a laser disc, a compact disc, a digital versatile disc (DVD), a floppy disc, and a Blu-ray disc, wherein the disc is usually magnetically copied,
  • the disc uses a laser to optically replicate the data. Combinations of the above should also be included within the scope of the computer readable media.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Disclosed are a method and device for obtaining a file; the method applies to a file system based on the sandbox mechanism. The method comprises: a browser receiving a file saving request initiated by an application programming interface of a first file system which is provided by a first application through the browser; saving the file needed to be stored by the first application in the file system according to the file saving request; receiving an instruction of obtaining the file triggered by a second application whose source is different from that of the first application, wherein the instruction carries the path of the file; and obtaining the path of the file, obtaining the file from the file system according to the path of the file, and providing the file to the second application. Embodiments of the present invention are applied to implement cross-source access in the file system.

Description

一种获取文件的方法和装置  Method and device for acquiring files
技术领域 本发明涉及通信技术领域, 特别涉及一种获取文件的方法和装置。 The present invention relates to the field of communications technologies, and in particular, to a method and apparatus for acquiring a file.
背景技术 随着互联网业务的发展, 万维网 web应用的使用越来越广泛。 web应用 是一种通过调用 web应用编程接口 ( application programming interface, API )来使浏览器执行该 web应用所要求的命令或动作的应用程序。 其中, web API为浏览器开放给 web应用程序的一个调用接口。 当前, 浏览器在开 放给应用的 API中提供了一组关于文件系统 filesystem的 API。 应用可通 过调用这些 filesystem API接口,将应用数据写入 f ilesystem0 f ilesysem 是基于沙盒 sandbox机制的文件系统, 以源 (origin) 为判断单位遵循谁 保存谁获取的原则, 不同源的应用无法获取对方的数据。 应用通过 filesystem API接口的调用, 指示浏览器为其分配一定大小的 file system 存储空间, 用来保存应用的数据, 并在应用自定义的 filesystem中读取与 写入文件及目录。 BACKGROUND OF THE INVENTION With the development of Internet services, the use of web applications for the World Wide Web has become more widespread. A web application is an application that causes a browser to execute commands or actions required by the web application by invoking a web application programming interface (API). Among them, the web API is a call interface that the browser opens to the web application. Currently, the browser provides a set of APIs for the file system filesystem in the API that is open to the application. Applications can be obtained by calling the filesystem API interfaces, application data is written f ilesystem 0 f ilesysem is a sandbox sandbox mechanism-based file system, the source (origin) to determine the unit who follow the principles of preservation who acquired from different sources can not be applied Get the other party's data. The application invokes the filesystem API interface to instruct the browser to allocate a file system storage space of a certain size, which is used to save the application data, and to read and write files and directories in the application-defined filesystem.
源(origin)是 URL的子集, 每个 web应用都有一个 URL。 源由应用的 URL中的规则 ( scheme )部分、 主机 ( host )部分和端口 ( port )部分组成。 由于规则不同 ( ¾。 hUps与 hup), 所以 hups:〃 www. hello, com页面和 http: //www. hello, com 页面的源是不同的。 源的概念不考虑路径, 如 http: //www. hel lo. com/ index, html和 hup: //www. hel lo. com/ ages, html 有相同的源。  The origin is a subset of the URL, and each web application has a URL. The source consists of the scheme part, the host part, and the port part of the application's URL. Due to different rules (3⁄4. hUps and hup), the source of the hups:〃 www. hello, com page and http: //www. hello, com page are different. The concept of the source does not take into account the path, such as http: //www.hel lo. com/ index, html and hup: //www.hel lo. com/ ages, html has the same source.
举例说明, 以下源为不同源:  For example, the following sources are different sources:
http: / / example, com/ http: / / example, com: 8080/ Http: / / example, com/ Http: / / example, com: 8080/
http: //www. example, com/  Http: //www. example, com/
hups: / / example, com: 80/  Hups: / / example, com: 80/
hups: / / example, com/  Hups: / / example, com/
http: //example, org/  Http: //example, org/
以下源为同源:  The following sources are homologous:
http: / / example, com/  Http: / / example, com/
http: / / example, com: 80/  Http: / / example, com: 80/
http: / / example, com/ ath/ file  Http: / / example, com/ ath/ file
现有技术中, 应用通过浏览器自动保存的文件, 直接由浏览器保存 到用户设备上的 filesystem中, 且仅有此浏览器可以直接操作 (如修改、 读取等 )之前保存的文件。 由于 filesystem是基于 s andbox机制的文件系 统, 因此, 应用通过浏览器自动保存的文件只能由与该应用同源的应用通 过该浏览器来获取,与该应用不同源的应用则无法获取到该文件,即源 A的 Web应用无法获取源 B的应用保存在 filesystem中的文件。  In the prior art, the file automatically saved by the browser is directly saved by the browser to the filesystem on the user device, and only the browser can directly operate (such as modifying, reading, etc.) the previously saved file. Since the filesystem is a file system based on the s andbox mechanism, the file automatically saved by the application through the browser can only be obtained by the application with the same application as the application, and the application different from the application cannot obtain the file. The file, that is, the source A web application cannot obtain the file of the source B application saved in the filesystem.
发明内容 本发明实施例提供一种获取文件的方法和装置, 以实现在 filesystem 中跨源获取文件。 SUMMARY OF THE INVENTION Embodiments of the present invention provide a method and an apparatus for acquiring a file, so as to obtain a file across a source in a filesystem.
第一方面, 获取文件的方法, 应用于基于沙盒 sandbox机制的文件系 统 filesystem, 该方法包括:  In the first aspect, the method for obtaining a file is applied to a file system filesystem based on a sandbox sandbox mechanism, and the method includes:
在浏览器接收第一应用通过所述浏览器提供的第一文件系统应用编程 接口 filesystem API发起的文件保存请求;  Receiving, by the browser, a file save request initiated by the first application by the first file system application programming interface filesystem API provided by the browser;
根据所述文件保存请求, 将所述第一应用需保存的文件保存到文件系 统 filesystem中; 接收与所述第一应用不同源的第二应用触发的获取所述文件的指令, 所述指令携带所述文件的路径; Saving the file to be saved by the first application to the file system filesystem according to the file save request; Receiving an instruction for acquiring the file triggered by a second application that is different from the first application, where the instruction carries a path of the file;
获取所述文件的路径, 并根据所述文件的路径从所述 f i lesys tem中获 取所述文件, 将所述文件提供给所述第二应用。  Obtaining a path of the file, and obtaining the file from the system according to a path of the file, and providing the file to the second application.
在第一方面的第一种可能的实现方式中, 该方法还包括:  In a first possible implementation manner of the first aspect, the method further includes:
记录所述文件的创建源, 所述创建源为保存所述文件的第一应用的源; 接收所述第一应用指定的所述文件的授权源, 所述授权源为被授权可 以获取所述文件的源;  Recording a creation source of the file, the creation source is a source of the first application that saves the file, and receiving an authorization source of the file specified by the first application, where the authorization source is authorized to obtain the Source of the file;
记录所述文件的授权源, 所述授权源中包括所述第二应用的源。  Recording an authorization source of the file, where the authorization source includes a source of the second application.
结合第一方面的第一种可能的实现方式, 在第二种可能的实现方式中, 所述根据所述文件的路径从所述第一应用的文件系统中获取所述文件, 将 所述文件提供给所述第二应用具体包括:  With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner, the acquiring the file from the file system of the first application according to the path of the file, Providing to the second application specifically includes:
根据所述文件的路径在所述 f i lesyetem中查找所述文件;  Locating the file in the f lesyetem according to the path of the file;
在查找到所述文件后, 将所述第二应用的源与所述文件的创建源以及 授权源进行匹配, 在确定所述第二应用的源为所述文件的授权源时, 将所 述文件提供给所述第二应用。  After finding the file, matching the source of the second application with the creation source of the file and the authorization source, and when determining that the source of the second application is an authorization source of the file, A file is provided to the second application.
结合第一方面或第一方面的第一种可能的实现方式或第一方面的第二 种可能的实现方式, 在第三种可能的实现方式中, 所述接收与所述第一应 用不同源的第二应用触发的获取所述文件的指令包括:  With reference to the first aspect, or the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, in a third possible implementation manner, the receiving is different from the first application The instructions for acquiring the file triggered by the second application include:
接收所述第二应用调用所述浏览器提供的第二 f i lesys tem API来获取 所述文件的调用指令。  Receiving, by the second application, a second trigger API provided by the browser to acquire a call instruction of the file.
结合第一方面的第三种可能的实现方式, 在第四种可能的实现方式中, 该方法还包括:  In conjunction with the third possible implementation of the first aspect, in a fourth possible implementation, the method further includes:
接收所述第一应用在保存所述文件后向所述第二应用发送的所述文件 的路径;  Receiving a path of the file sent by the first application to the second application after saving the file;
将所述文件的路径转发给所述第二应用, 以便所述第二应用根据所述 文件的路径发起所述调用指令。 Forwarding the path of the file to the second application, so that the second application is according to the The path of the file initiates the call instruction.
结合第一方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述文件的路径携带在所述第一应用向第二应用发送的跨文档通信消息 postMessage中, 或,携带在所述第一应用向第二应用发送的超文本传输协 议 HTTP消息中。  With the fourth possible implementation of the first aspect, in a fifth possible implementation, the path of the file is carried in a cross-document communication message postMessage sent by the first application to the second application, or And carried in the Hypertext Transfer Protocol (HTTP) message sent by the first application to the second application.
结合第一方面的第一种可能的实现方式, 在第六种可能的实现方式中, 所述方法还包括:  In conjunction with the first possible implementation of the first aspect, in a sixth possible implementation, the method further includes:
浏览器接收所述第二应用通过 file API发起的文件获取请求, 所述文 件获取请求指示浏览器釆用用户选择的方式获取文件;  The browser receives a file acquisition request initiated by the second application by using the file API, where the file acquisition request instructs the browser to acquire the file by using a manner selected by the user;
浏览器根据所述文件获取请求打开文件选择界面, 并在所述文件选择 界面中展现 filesystem中的可选文件;  The browser opens a file selection interface according to the file acquisition request, and displays an optional file in the filesystem in the file selection interface;
所述接收与所述第一应用不同源的第二应用触发的获取所述文件的指 令包括: 接收用户在所述文件选择界面中, 选择所述文件的指令。  The instruction for acquiring the file triggered by the second application receiving the different source of the first application comprises: receiving an instruction of the user to select the file in the file selection interface.
结合第一方面的第六种可能的实现方式, 在第七种可能的实现方式中, 所述在所述文件选择界面中展现 filesystem中的可选文件包括:  In conjunction with the sixth possible implementation of the first aspect, in a seventh possible implementation, the displaying, in the file selection interface, the optional file in the filesystem includes:
浏览器确定 filesystem中可被所述第二应用获取的可选文件, 为每个 可选文件生成一个关联的虚拟文件, 以所述可选文件的路径作为与所述虚 拟文件关联的信息, 并将生成的虚拟文件展现在所述文件选择界面中, 以 便所述用户通过所述虚拟文件来选择与所述虚拟文件关联的文件。  The browser determines an optional file in the filesystem that can be obtained by the second application, generates an associated virtual file for each optional file, and uses the path of the optional file as the information associated with the virtual file, and The generated virtual file is presented in the file selection interface such that the user selects a file associated with the virtual file through the virtual file.
结合第一方面的第六种可能或第一方面的第七种可能的实现方式, 在 第八种可能的实现方式中, 在所述文件选择界面中展现 filesystem中的可 选文件前, 还包括: 生成 filesystem虚拟文件夹, 并将所述 filesystem 虚拟文件夹作为系统盘展现在所述文件选择界面中, 在接收到用户选择所 述 filesystem虚拟文件夹的操作后执行所述在所述文件选择界面中展现 filesystem中的可选文件的操作。  In conjunction with the sixth possible aspect of the first aspect or the seventh possible implementation of the first aspect, in an eighth possible implementation, before the optional file in the filesystem is displayed in the file selection interface, : generating a filesystem virtual folder, and displaying the filesystem virtual folder as a system disk in the file selection interface, and executing the file selection interface after receiving an operation of the user selecting the filesystem virtual folder The operation of displaying optional files in filesystem.
结合第一方面的第八种可能的实现方式, 在第九种可能的实现方式中, 所述浏览器确定 filesystem中可被所述第二应用获取的可选文件时, 还包 括: 确定所述可选文件的创建源, 并分别生成各创建源的虚拟文件夹; 所述将生成的虚拟文件展现在所述文件选择界面中具体包括: 将所述 创建源的虚拟文件夹作为所述 filesystem虚拟文件夹中的子文件夹, 并根 将所述可选文件的虚拟文件放在对应的创建源的虚拟文件夹中, 作为所述 创建源的虚拟文件夹中的子文件展现。 In conjunction with the eighth possible implementation of the first aspect, in a ninth possible implementation manner, When the browser determines an optional file that can be obtained by the second application in the filesystem, the method further includes: determining a creation source of the optional file, and respectively generating a virtual folder of each creation source; The virtual file being displayed in the file selection interface specifically includes: using the virtual folder of the creation source as a subfolder in the filesystem virtual folder, and placing the virtual file of the optional file in a corresponding In the virtual folder of the creation source, the subfiles in the virtual folder as the creation source are presented.
结合第一方面的第六种可能或第一方面的第七种可能或第一方面的第 八种可能或第一方面的第九种可能的实现方式, 在第十种可能的实现方式 中, 所述浏览器确定 filesystem中可被所述第二应用获取的可选文件具体 包括:  Combining the sixth possibility of the first aspect or the seventh possibility of the first aspect or the eighth possible aspect of the first aspect or the ninth possible implementation manner of the first aspect, in a tenth possible implementation manner, The browser determines that the optional file that can be obtained by the second application in the filesystem specifically includes:
将创建源包括所述第二应用的源的文件, 以及授权源包括所述第二应 用的源的文件确定为 filesystem中可被所述第二应用获取的可选文件。  A file that creates a source including the source of the second application, and a file whose source of authorization includes the source of the second application is determined to be an optional file in the filesystem that is obtainable by the second application.
第二方面, 一种获取文件的装置, 应用于基于沙盒 sandbox机制的文 件系统 filesystem, 所述装置包括:  In a second aspect, a device for acquiring a file is applied to a file system filesystem based on a sandbox sandbox mechanism, the device comprising:
接口单元, 用于提供第一文件系统应用编程接口 filesystem API; 请求处理单元, 用于接收第一应用通过所述接口单元提供的第一 filesystem API发起的文件保存请求;  An interface unit, configured to provide a first file system application programming interface filesystem API, and a request processing unit, configured to receive a file save request initiated by the first filesystem API provided by the first application by the interface unit;
保存单元, 用于根据所述请求处理单元接收到的文件保存请求, 将所 述第一应用需保存的文件保存到文件系统 f i 1 e s y s t em中;  a saving unit, configured to save the file to be saved by the first application to the file system f i 1 e s y s t em according to the file save request received by the request processing unit;
事件处理单元, 用于接收与所述第一应用不同源的第二应用触发的获 取所述第一应用保存的文件的指令, 所述指令携带所述文件的路径;  An event processing unit, configured to receive an instruction for acquiring a file saved by the first application triggered by a second application that is different from the first application, where the instruction carries a path of the file;
获取单元, 用于从所述事件处理单元接收的指令中获取所述文件的路 径, 并根据所述文件的路径从所述 filesystem中获取所述文件;  An obtaining unit, configured to acquire a path of the file from an instruction received by the event processing unit, and obtain the file from the filesystem according to a path of the file;
提供单元, 用于将所述获取单元获取的文件提供给所述第二应用。 在第二方面的第一种可能的实现方式中, 所述请求处理单元, 还用于 接收所述第一应用指定的所述文件的授权源, 所述授权源为被授权可以获 取所述文件的源; And a providing unit, configured to provide the file acquired by the acquiring unit to the second application. In a first possible implementation manner of the second aspect, the request processing unit is further configured to receive an authorization source of the file specified by the first application, where the authorization source is authorized to obtain Take the source of the file;
所述保存单元, 还用于记录所述文件的创建源和所述文件的授权源, 所述创建源为保存所述文件的第一应用的源; 所述授权源中包括所述第二 应用的源。  The saving unit is further configured to record a creation source of the file and an authorization source of the file, where the creation source is a source of a first application that saves the file, and the authorization source includes the second application. Source.
结合第二方面的第一种可能的实现方式, 在第二种可能的实现方式中, 所述获取单元具体包括:  With reference to the first possible implementation of the second aspect, in a second possible implementation, the acquiring unit specifically includes:
获取子单元, 用于从所述事件处理单元接收的指令中获取所述文件的 路径;  Obtaining a subunit, configured to acquire a path of the file from an instruction received by the event processing unit;
查找子单元,用于根据所述获取子单元获取的路径,在所述 f i lesys tem 中查找所述文件;  a searching subunit, configured to search for the file in the f i lesys according to the path obtained by the obtaining subunit;
鉴权子单元, 用于在所述查找子单元查找到所述文件后, 将所述第二 应用的源与所述文件的创建源和授权源进行匹配, 在确定所述第二应用的 源为所述文件的授权源时, 通知所述提供单元将所述查找模块查找到的文 件发送给所述第二应用。  An authentication subunit, configured to: after the searching subunit finds the file, match a source of the second application with a creation source and an authorization source of the file, and determine a source of the second application. When the authorization source is the file, the providing unit is notified to send the file found by the searching module to the second application.
结合第二方面或第二方面的第一种可能的实现方式或第二方面的第二 种可能的实现方式, 在第三种可能的实现方式中, 所述接口单元还用于提 供第二 f i lesys tem API接口;  With reference to the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect, in a third possible implementation, the interface unit is further configured to provide the second fi Lesys tem API interface;
所述事件处理单元通过所述接口单元提供的第二 f i lesys tem API接收 所述第二应用触发的获取所述文件的调用指令。  And the event processing unit receives, by using the second terminal API provided by the interface unit, the calling instruction that is triggered by the second application to acquire the file.
结合第二方面的第三种可能的实现方式, 在第四种可能的实现方式中, 所述装置还包括:  In conjunction with the third possible implementation of the second aspect, in a fourth possible implementation, the device further includes:
转发单元, 用于接收所述第一应用在保存所述文件后向所述第二应用 发送的所述文件的路径; 并将所述文件的路径转发给所述第二应用, 以便 所述第二应用根据所述文件的路径发起所述调用指令。  a forwarding unit, configured to receive a path of the file sent by the first application to the second application after saving the file, and forward a path of the file to the second application, so that the The second application initiates the call instruction according to the path of the file.
结合第二方面的第四种可能的实现方式, 在第五种可能的实现方式中, 所述文件的路径携带在所述第一应用向第二应用发送的跨文档通信消息 pos tMes sage中, 或,携带在所述第一应用向第二应用发送的超文本传输协 议 HTTP消息中。 With reference to the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner, the path of the file carries a cross-document communication message sent by the first application to the second application In the pos tMes sage, or in the Hypertext Transfer Protocol HTTP message sent by the first application to the second application.
结合第二方面的第一种可能的实现方式, 在第六种可能的实现方式中, 所述接口单元, 还用于提供 f i le API ;  In conjunction with the first possible implementation of the second aspect, in a sixth possible implementation, the interface unit is further configured to provide a f i le API;
所述事件处理单元具体包括:  The event processing unit specifically includes:
接收子单元,用于接收所述第二应用通过所述接口单元提供的 f i le API 发起的文件获取请求, 所述文件获取请求指示釆用用户选择的方式获取文 件;  a receiving subunit, configured to receive a file obtaining request initiated by the second application through the interface provided by the interface unit, where the file obtaining request indicates that the file is obtained by using a mode selected by the user;
交互子单元, 用于根据所述接收子单元接收的文件获取请求打开文件 选择界面, 在所述文件选择界面中展现 f i lesys tem中的可选文件, 并接收 用户在所述文件选择界面中, 选择所述第一应用保存的文件的指令。  An interaction subunit, configured to open a file selection interface according to the file acquisition request received by the receiving subunit, and display an optional file in the file in the file selection interface, and receive the user in the file selection interface, An instruction to select a file saved by the first application.
结合第二方面的第六种可能的实现方式, 在第七种可能的实现方式中, 所述交互子单元具体包括:  With reference to the sixth possible implementation of the second aspect, in a seventh possible implementation, the interaction sub-unit specifically includes:
界面模块, 用于根据所述接收子单元接收的文件获取请求打开文件选 择界面;  An interface module, configured to open a file selection interface according to a file acquisition request received by the receiving subunit;
内容模块,用于确定 f i lesys tem中可被所述第二应用获取的可选文件; 生成模块, 用于为内容模块确定的每个可选文件生成一个关联的虚拟 文件, 以所述可选文件的路径作为与所述虚拟文件关联的信息,  a content module, configured to determine an optional file in the system that can be obtained by the second application; a generating module, configured to generate an associated virtual file for each optional file determined by the content module, to select the The path of the file as the information associated with the virtual file,
展现模块, 用于将生成模块生成的虚拟文件展现在所述界面模块打开 的文件选择界面中, 以便所述用户通过所述虚拟文件来选择与所述虚拟文 件关联的文件;  a presentation module, configured to display the virtual file generated by the generation module in a file selection interface opened by the interface module, so that the user selects a file associated with the virtual file by using the virtual file;
事件模块, 用于接收用户在所述文件选择界面中, 选择所述第一应用 保存的文件的指令。  And an event module, configured to receive an instruction that the user selects a file saved by the first application in the file selection interface.
结合第二方面的第六种可能或第二方面的第七种可能的实现方式, 在 第八种可能的实现方式中, 所述生成模块, 还用于生成 f i lesys tem虚拟文 件夹; 所述展现模块, 还用于将所述生成子模块生成的 filesystem虚拟文件 夹作为系统盘展现在所述文件选择界面中; With reference to the sixth possible aspect of the second aspect, or the seventh possible implementation manner of the second aspect, in the eighth possible implementation, the generating module is further configured to generate a virtual folder; The presentation module is further configured to display the filesystem virtual folder generated by the generating submodule as a system disk in the file selection interface;
所述事件模块还用于接收用户选择所述 filesystem虚拟文件夹的操 作, 并在接收到所述操作后指示所述展现模块执行所述在所述文件选择界 面中展现 filesystem中的可选文件的操作。  The event module is further configured to receive an operation of the user selecting the filesystem virtual folder, and after receiving the operation, instructing the presentation module to perform the displaying the optional file in the filesystem in the file selection interface. operating.
结合第二方面的第八种可能的实现方式, 在第九种可能的实现方式中, 所述内容模块, 还用于确定所述可选文件的创建源;  With reference to the eighth possible implementation of the second aspect, in a ninth possible implementation, the content module is further configured to determine a source of creation of the optional file;
所述生成模块, 还用于分别生成所述内容模块确定的各创建源的虚拟 文件夹;  The generating module is further configured to separately generate a virtual folder of each creation source determined by the content module;
所述展现模块具体包括:  The presentation module specifically includes:
第一展现子模块, 用于将所述生成模块生成的 filesystem虚拟文件夹 作为系统盘展现在所述文件选择界面中;  a first presentation submodule, configured to display the filesystem virtual folder generated by the generating module as a system disk in the file selection interface;
第二展现子模块, 用于将所述生成模块生成的所述创建源的虚拟文件 夹作为所述 filesystem虚拟文件夹中的子文件夹展现;  a second presentation submodule, configured to display the virtual folder of the creation source generated by the generation module as a subfolder in the filesystem virtual folder;
第三展现子模块, 用于将所述生成模块生成的所述可选文件的虚拟文 件放在对应的创建源的虚拟文件夹中, 作为所述创建源的虚拟文件夹中的 子文件展现。  And a third presentation submodule, configured to place the virtual file of the optional file generated by the generation module in a virtual folder of the corresponding creation source, as a subfile presentation in the virtual folder of the creation source.
结合第二方面的第六种可能或第二方面的第七种可能或第二方面的第 八种可能或第二方面的第九种可能的实现方式, 在第十种可能的实现方式 中, 所述 filesystem中可被所述第二应用获取的可选文件包括: 创建源包 括所述第二应用的源的文件, 以及授权源包括所述第二应用的源的文件。  With reference to the sixth possible aspect of the second aspect or the seventh possible aspect of the second aspect or the ninth possible implementation of the eighth possible aspect or the second aspect, in a tenth possible implementation manner, The optional file that can be obtained by the second application in the filesystem includes: a file whose creation source includes the source of the second application, and a file whose source of authorization includes the source of the second application.
本发明实施例, 可以在基于沙盒机制的文件系统 filesystem中, 向浏 览器提供不同源的应用保存的文件的路径, 从而实现了跨源的文件获取。  In the embodiment of the present invention, the path of the file saved by the application of different sources may be provided to the browser in the file system filesystem based on the sandbox mechanism, thereby realizing the cross-source file acquisition.
附图说明 为了更清楚地说明本发明实施例的技术方案, 下面将对实施例中所需 要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是本发 明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的 前提下, 还可以根据这些附图获得其他的附图。 DRAWINGS In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. One of ordinary skill in the art can also obtain other drawings based on these drawings without undue creative effort.
图 1为本发明实施例的获取文件的方法流程图;  FIG. 1 is a flowchart of a method for acquiring a file according to an embodiment of the present invention;
图 2为本发明另一实施例提供获取文件的方法流程图;  2 is a flowchart of a method for obtaining a file according to another embodiment of the present invention;
图 3为本发明另一实施例提供获取文件的方法流程图;  3 is a flowchart of a method for obtaining a file according to another embodiment of the present invention;
图 4为本发明实施例提供在应用场景下获取文件的方法流程图; 图 5在应用场景下获取文件的方法的另一实施例的流程图;  FIG. 4 is a flowchart of a method for acquiring a file in an application scenario according to an embodiment of the present invention; FIG. 5 is a flowchart of another embodiment of a method for acquiring a file in an application scenario;
图 6为本发明实施例提供的 f i lesys tem虚拟文件夹的界面示意图; 图 7为本发明实施例提供创建源的虚拟文件夹的展示界面示意图; 图 8为本发明实施例提供虚拟文件的展示界面示意图;  FIG. 6 is a schematic diagram of an interface of a virtual folder of a virtual thread according to an embodiment of the present invention; FIG. 7 is a schematic diagram of a display interface of a virtual folder for creating a source according to an embodiment of the present invention; FIG. 8 is a schematic diagram of providing a virtual file according to an embodiment of the present invention; Interface diagram;
图 9为本发明实施例提供一种获取文件的装置的结构示意图; 图 10为本发明另一实施例提供一种获取文件的装置的结构示意图; 图 11为本发明另一实施例一种获取文件的装置的结构示意图; 图 12为本发明实施例提供一种获取文件的装置的层次划分结构图; 图 13为本发明实施例提供一种获取文件的装置的硬件结构示意图。  FIG. 9 is a schematic structural diagram of an apparatus for acquiring a file according to an embodiment of the present invention; FIG. 10 is a schematic structural diagram of an apparatus for acquiring a file according to another embodiment of the present invention; FIG. 12 is a schematic structural diagram of a device for acquiring a file according to an embodiment of the present invention; FIG. 13 is a schematic diagram of a hardware structure of an apparatus for acquiring a file according to an embodiment of the present invention.
具体实施方式 下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进 行清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没 有作出创造性劳动前提下所获得的所有其他实施例, 都属于本发明保护的 范围。 The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. example. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例中的源包括应用的统一资源定位器 URL 中的规则部分、 主机部分以及端口部分。 The source in the embodiment of the present invention includes a rule part in the Uniform Resource Locator URL of the application, Host part and port part.
图 1 为本发明实施例提供的获取文件的方法流程图, 该方法可应用于 基于沙盒 sandbox机制的文件系统 filesystem。 如图所示, 该实施例中获 取文件的方法包括:  FIG. 1 is a flowchart of a method for acquiring a file according to an embodiment of the present invention. The method can be applied to a file system filesystem based on a sandbox sandbox mechanism. As shown in the figure, the method for obtaining a file in this embodiment includes:
S100, 浏览器接收第一应用通过该浏览器提供的第一文件系统应用编 程接口 filesystem API发起的文件保存请求。  S100. The browser receives a file save request initiated by the first application through the first file system application programming interface filesystem API provided by the browser.
其中, 第一应用为在浏览器中运行的应用, 如, web应用。  The first application is an application running in a browser, such as a web application.
第一文件系统应用编程接口 filesystem API 可以包括至少一个 filesystem API。具体的,第一应用可通过调用 filesystem API中的 getFile API和 Write API来发起文件保存请求。 其中, getFi le用于获取文件入口, Write用于向文件中写入要保存的数据。 即, 第一应用先获取 filesystem 文件, 再在文件内写入要保存的数据。 获取文件可以为:  The first file system application programming interface filesystem API can include at least one filesystem API. Specifically, the first application can initiate a file save request by calling the getFile API and the Write API in the filesystem API. Among them, getFi le is used to get the file entry, Write is used to write the data to be saved to the file. That is, the first application first obtains the filesystem file, and then writes the data to be saved in the file. Obtaining a file can be:
getFi le ( "DOMString path" , {create: true} );  getFi le ( "DOMString path" , {create: true} );
其中, "DOMString path" 为文件路径。 在 filesystem 中, 由发起文 件保存的应用指定文件的保存路径, 并以该路径作为文件标识符来唯一标 识该文件。 例如, getFile ( "/BenPicture/Ben. jpg", {create: true} ); 其 中 , " /BenPicture/Ben. jpg " 可视为 文件的标识符 , 通过 "/BenPicture/Ben. jpg" 可获取到要保存的文件的入口。 {create: true} 表示如果该文件不存在, 则创建该文件。  Where "DOMString path" is the file path. In filesystem, the application saved by the originating file specifies the path to save the file and uses that path as the file identifier to uniquely identify the file. For example, getFile ( "/BenPicture/Ben. jpg", {create: true} ); where " /BenPicture/Ben. jpg " can be considered as the identifier of the file, which can be obtained by "/BenPicture/Ben. jpg" The entry to the file to save. {create: true} means that if the file does not exist, it is created.
需要说明的是, 不同的应用可以在 filesystem 中申请自 己的 filesystem 空间。 所以, 第一应用在发起文件保存请求时, 还可以调用 filesystem API中的 reques tFi leSys tem API来指示浏览器为其分配一定 大小的 file system存储空间, 用来保存第一应用的文件。  It should be noted that different applications can apply for their own filesystem space in filesystem. Therefore, when the first application initiates the file save request, the reques tFi leSystem API in the filesystem API may be invoked to instruct the browser to allocate a file system storage space of a certain size for saving the file of the first application.
由于, 应用申请了自己的 filesystem空间, 所以同一个源可能存在有 不同的 filesystem 的情况。 但每次应用通过 reques tf i lesys tern 申请 filesystem空间, 浏览器都会返回唯一的对象给请求的应用, 用于唯一标 识每个 filesystem,应用保存文件时,还可在保存请求中携带该 f i 1 e s y s t em 标识。 S102, 根据所述文件保存请求, 将所述第一应用需保存的文件保存 到文件系统 filesystem中。 Because the application has applied for its own filesystem space, there may be different filesystems for the same source. But each time the application requests a filesystem space through reques tf i lesys tern, the browser will return a unique object to the requested application, for unique identifiers. Know each filesystem, when the application saves the file, you can also carry the fi 1 esyst em identifier in the save request. S102. Save the file to be saved by the first application to the file system filesystem according to the file save request.
具体的, 浏览器在 filesystem中找到 getFile中的 "DOMString path" 指定的文件, 并将第一应用要保存的数据写入该文件中, 写入数据后的该 文件即为第一应用保存的文件。 如果 filesystem 中不存在 "DOMString path" 指定的文件, 则创建该文件, 再将要保存的数据写入该文件中。  Specifically, the browser finds the file specified by "DOMString path" in the getFile in the filesystem, and writes the data to be saved by the first application into the file, and the file after the data is written is the file saved by the first application. . If the file specified by "DOMString path" does not exist in filesystem, create the file and write the data to be saved to the file.
S 104 , 接收与所述第一应用不同源的第二应用触发的获取所述文件的 指令, 该指令携带所述文件的路径。  S104. Receive an instruction for acquiring the file triggered by a second application that is different from the first application, where the instruction carries a path of the file.
第二应用为在浏览器中运行的应用。 通过第二应用的 URL可获知第二 应用的源。  The second application is an application that runs in a browser. The source of the second application is known by the URL of the second application.
在每个应用申请有自己的 filesystem空间的情况下, 该指令还可携带 该 f i lesys tem标识。  In the case that each application has its own filesystem space, the instruction may also carry the identifier.
S 106 ,获取所述文件的路径,并根据所述文件的路径从所述 filesystem 中获取所述文件, 并将所述文件提供给第二应用。  S106. Obtain a path of the file, and obtain the file from the filesystem according to the path of the file, and provide the file to a second application.
具体的, 浏览器可以从接收的指令中获取文件的路径。  Specifically, the browser can obtain the path of the file from the received instruction.
可选的, 在指令中携带 filesystem标识时, 浏览器从该 filesystem 标识指定的 filesystem中获取所述文件。  Optionally, when the filesystem identifier is carried in the instruction, the browser obtains the file from the filesystem specified by the filesystem identifier.
上述实施例, 可以在基于沙盒机制的文件系统 filesystem中, 向浏览 器提供不同源的应用保存的文件的路径, 从而实现了跨源的文件获取。  In the above embodiment, the path of the file saved by the application of different sources may be provided to the browser in the file system filesystem based on the sandbox mechanism, thereby realizing the cross-source file acquisition.
本发明实施例中, 第二应用要获取第一应用保存在 filesystem中的文 件时, 可釆用下述两种方式来通知浏览器:  In the embodiment of the present invention, when the second application acquires the file saved by the first application in the filesystem, the browser can be notified in the following two ways:
方式一: 第二应用可调用浏览器提供的第二 filesystem API来指示浏 览器从第一应用的 filesystem中获取文件, 并在调用 filesystem API时 指定要获取的文件的路径。  Method 1: The second application may invoke a second filesystem API provided by the browser to instruct the browser to obtain the file from the filesystem of the first application, and specify the path of the file to be obtained when the filesystem API is called.
方式二:第二应用可以调用浏览器提供的 file API发起文件获取请求, 如<1叩1^ type="file">, 通过该文件获取请求指示浏览器提供文件选择界 面给用户, 使用户在文件选择界面中选择要提供给第二应用的文件。 Method 2: The second application can invoke a file API provided by the browser to initiate a file acquisition request. For example, <1叩1^ type="file">, the file obtaining request instructs the browser to provide a file selection interface to the user, so that the user selects a file to be provided to the second application in the file selection interface.
需要说明的是, 无论釆用上述哪种方式, 均要由第二应用来触发。 在釆用方式一来实现本发明的实施例中, 步骤 104 中的接收与第一应 用不同源的第二应用触发的获取所述文件的指令具体可包括: 接收第二应 用调用浏览器提供的第二 filesystem API来获取第一应用保存的文件的调 用指令。 其中, 第二应用提供给浏览器的路径信息, 可以是第一应用在保 存该文件后发送给第二应用的。 具体的处理流程可参见图 2。  It should be noted that regardless of which of the above methods is used, it is triggered by the second application. In an embodiment of the present invention, the instruction for acquiring the file triggered by the second application that is different from the first application in the step 104 may include: receiving the second application to invoke the browser. The second filesystem API is to obtain a call instruction of the file saved by the first application. The path information provided by the second application to the browser may be sent by the first application to the second application after saving the file. The specific processing flow can be seen in Figure 2.
图 2为釆用方式一来指示浏览器获取文件的方法流程图, 如图 2所示, 该方法包括:  FIG. 2 is a flowchart of a method for instructing a browser to acquire a file, as shown in FIG. 2, the method includes:
S200, 浏览器接收第一应用通过该浏览器提供的第一文件系统应用编 程接口 filesystem API发起的文件保存请求。  S200. The browser receives a file save request initiated by the first application through the first file system application programming interface filesystem API provided by the browser.
S202, 根据所述文件保存请求, 将所述第一应用需保存的文件保存到 文件系统 filesystem中。  S202. Save the file to be saved by the first application to the file system filesystem according to the file save request.
步骤 S200-S202的具体实现可参考图 1所示实施例, 这里不再赘述。 For the specific implementation of the steps S200-S202, reference may be made to the embodiment shown in FIG. 1, and details are not described herein again.
S204, 在第一应用保存文件后, 浏览器接收第一应用向第二应用发送 的该文件的路径; 并将该文件的路径转发给第二应用, 以便第二应用根据 所述文件的路径发起调用指令。 S204: After the first application saves the file, the browser receives the path of the file sent by the first application to the second application, and forwards the path of the file to the second application, so that the second application initiates according to the path of the file. Call the instruction.
具体的, 第一应用可以通过跨文档通信消息 postMessage将文件的存 储信息发送给第二应用, 并指示第二应用从 filesystem中获取文件。  Specifically, the first application may send the storage information of the file to the second application by using the cross-document communication message postMessage, and instruct the second application to obtain the file from the filesystem.
postMessage的消息格式如下:  The message format of postMessage is as follows:
postMessage ( "f ilesystemRetrieve: DOMString path" , "第二应 用 URL" );  postMessage ( "f ilesystemRetrieve: DOMString path" , "second application URL");
其中 "f ilesystemRetrieve: DOMString path" 是消息内容字段, f ilesystemRetrieve 表示 ": " 后 "DOMString path" 所指示的文件要从 filesystem获取; 冒号后的 "DOMString path" 为文件在 fi lesys tem中的 保存路径, 可作为文件的标识符, 用于在 filesystem中唯一标识并找到该 文件; "第二应用的 URL" 是消息目的地字段。 Where "f ilesystemRetrieve: DOMString path" is the message content field, f ilesystemRetrieve means ":" after the "DOMString path" indicates that the file is to be fetched from filesystem; after the colon "DOMString path" is the file in fi lesys tem The save path, which can be used as an identifier for the file, is used to uniquely identify and locate the file in the filesystem; "The URL of the second application" is the message destination field.
当然, 也可以通过其他方式, 譬如将 f ilesystemRetrieve单独设为一 个字段, 表示从 filesystem获取文件, 而 "DOMString path" 则放在消息 内容字段中, 格式如下:  Of course, other methods, such as setting ilesystemRetrieve as a field, to obtain files from filesystem, and "DOMString path" in the message content field, the format is as follows:
postMessage ( " DOMString path " , "第二应用 的 URL,, , "f ilesystemRetrieve" );  postMessage ( " DOMString path " , " URL of the second application,, , "f ilesystemRetrieve" );
可选的, 第一应用还可以通过超文本传输协议( Hypertext Transfer Protocol, HTTP)将文件的存储信息发送给第二应用。 例如, 可在第一应 用定向到第二应用时, 在第一应用发送给第二应用的 GET 消息增加 "文件 路径" 和 "f ilesystemRetrieve" 两个标识, 具体格式如下:  Optionally, the first application may further send the storage information of the file to the second application by using a Hypertext Transfer Protocol (HTTP). For example, when the first application is directed to the second application, the "file path" and "f ilesystemRetrieve" identifiers are added to the GET message sent by the first application to the second application, and the specific format is as follows:
GEThttp:〃第二应用的 URL/?filesystemRetrieve= "DOMString path" head;  GEThttp: 〃 second application URL /? filesystemRetrieve = "DOMString path" head;
其中, filesystemRetrieve表示 "=" 后 "DOMString path" 所表示 的文件要从 filesystem 获取; 等号后的 "DOMString path" 为文件在 filesystem中的保存路径; "第二应用的 URL" 表示定向到第二应用。  Where filesystemRetrieve indicates that "="DOMString path" represents the file to be retrieved from filesystem; "DOMString path" after the equal sign is the file save path in filesystem; "second application URL" indicates orientation to second application.
S206, 接收第二应用调用浏览器提供的第二 filesystem API来获取第 一应用保存的文件的调用指令。  S206. Receive a second application that invokes a second filesystem API provided by the browser to obtain a call instruction of the file saved by the first application.
第二应用在接收到第一应用发送的文件存储信息后, 获知需要从 filesystem中获取文件, 因此, 调用浏览器提供的第二 f i lesys tem API来 获取文件, 并在调用指令中携带该文件的路径。  After receiving the file storage information sent by the first application, the second application knows that the file needs to be obtained from the filesystem. Therefore, the second function provided by the browser is used to obtain the file, and the file is carried in the calling instruction. path.
其中, 第二 filesystem API可以包括至少一个 filesystem API, 而且 可以包括第一 filesystem API中的 filesystem API, 例如, 第二应用可调 用 getfile API和 FileReaderAPI来指示浏览器获取文件。 其中, getFile 用于获取文件入口, FileReader用于从 getFile找到的文件中读取数据。 第二应用将从第一应用接收到的文件的路径携带在 getFile中,如, getFile ("DOMString path")。 The second filesystem API may include at least one filesystem API, and may include a filesystem API in the first filesystem API. For example, the second application may invoke the getfile API and the FileReaderAPI to instruct the browser to obtain the file. Among them, getFile is used to get the file entry, and FileReader is used to read the data from the file found by getFile. The second application carries the path of the file received from the first application in getFile, for example, getFile ("DOMString path").
S208,获取所述文件的路径,并根据所述文件的路径从所述 filesystem 中获取所述文件, 将所述文件给第二应用。  S208. Obtain a path of the file, and obtain the file from the filesystem according to the path of the file, and send the file to a second application.
上述实施例通过扩展第一应用和第二应用之间的交互消息, 将第一应 用保存在 filesystem中的文件的路径发送给第二应用, 使得第二应用可以 通过该路径获取到第一应用保存在 filesystem中的文件, 从而实现跨源访 问。  The foregoing embodiment sends the path of the file saved by the first application in the file system to the second application by extending the interaction message between the first application and the second application, so that the second application can obtain the first application by using the path. Files in filesystem for cross-source access.
可选的, 为了增加在跨源访问过程中的安全性, 本发明实施例还可以 允许第一应用指定授权源, 其它源只有在第一应用指定的授权源中才可获 取第一应用保存的文件。  Optionally, in order to increase the security in the process of the cross-source access, the embodiment of the present invention may further allow the first application to specify the authorization source, and the other source may obtain the saved by the first application only in the authorization source specified by the first application. file.
具体的,在步骤 S206之前还可以进一步包括:记录所述文件的创建源, 所述创建源为保存所述文件的第一应用的源; 接收第一应用指定的所述文 件的授权源, 所述授权源为被授权可以获取所述文件的源; 记录所述文件 的授权源, 所述文件的授权源中包括所述第二应用的源。  Specifically, before the step S206, the method further includes: recording a creation source of the file, where the creation source is a source of the first application that saves the file, and receiving an authorization source of the file specified by the first application, where The authorization source is a source that is authorized to obtain the file; an authorization source of the file is recorded, and an authorization source of the file includes a source of the second application.
其中, 浏览器可以扩展以下 filesystem API, 使第一应用通过以下 filesystem API来指定 4受权源, 比如:  The browser can extend the following filesystem API to enable the first application to specify 4 authorized sources through the following filesystem API, such as:
a.浏览器可以扩展 getFile API,使第一应用可以使用浏览器提供的此 API在 S202的文件保存请求中指定授权源。 如:  a. The browser can extend the getFile API so that the first application can specify the authorization source in the file save request of S202 using the API provided by the browser. Such as:
void getFile (DOMString path, {create: true} , optional DOMString Pemissions);  Void getFile (DOMString path, {create: true} , optional DOMString Pemissions);
其中, "DOMString path" 为文件路径, 用于唯一标识 filesystem 中 的文件, "DOMString Pemiss ions"为新增字段,表示 4受权源。 例如: getFile ( "/BenPicture/Ben. jpg", {create: ture} , "*. drawing, com" ), 则表示 图片 /BenPicture/Ben. jpg可以被 *. drawing, com的源获取。  Among them, "DOMString path" is a file path, which is used to uniquely identify the file in filesystem, and "DOMString Pemiss ions" is a new field, indicating 4 authorized sources. For example: getFile ( "/BenPicture/Ben. jpg", {create: ture} , "*. drawing, com" ), then the picture /BenPicture/Ben. jpg can be obtained from the source of *. drawing, com.
b.浏览器可以扩展 requestFileSystem API,使第一应用使用浏览器提 供的此 API 在获取 filesystem 空间的时候指定授权源, 此授权源对 f ilesystem空间下的所有文件 生效。 口: b. The browser can extend the requestFileSystem API, so that the first application uses the API provided by the browser to specify the authorization source when obtaining the filesystem space. All files in the ilesystem space take effect. mouth:
void reques tFi leSys tern (..., optional DOMString Pemissions); 其中, "DOMString Pemissions" 为新增字段, 表示授权源。  Void reques tFi leSys tern (..., optional DOMString Pemissions); where "DOMString Pemissions" is a new field that represents the authorization source.
c浏览器可以扩展一个新的 API,使第一应用使用浏览器提供此新增 API指定文件授权源。 如:  The c browser can extend a new API so that the first application uses the browser to provide this new API to specify the file authorization source. Such as:
createFilePermissions (DOMString path, DOMString Pemissions); 其中, createFilePermissions 为新增 API, "DOMString path" 为 文件路径, 用于唯一标识 f ilesystem中的文件, "DOMString Pemissions" 为授权源。  createFilePermissions (DOMString path, DOMString Pemissions); where createFilePermissions is the new API, "DOMString path" is the file path, which is used to uniquely identify the files in the fleetsystem, and "DOMString Pemissions" is the authorization source.
需要说明的是, 可以指定一个或多个授权源, 浏览器可以创建关系表 来记录文件与创建源以及授权源的关系, 如表 1所示:  It should be noted that one or more authorization sources can be specified, and the browser can create a relationship table to record the relationship between the file and the creation source and the authorization source, as shown in Table 1:
表 1
Figure imgf000016_0001
可选的, 步骤 208 中的根据文件的路径从第一应用的文件系统中获取 所述文件, 将所述文件提供给所述第二应用具体可包括: 根据文件的路径 在 filesyetem中查找所述文件; 在查找到所述文件后, 将第二应用的源与 所述文件的创建源以及授权源进行匹配, 在确定第二应用的源为所述文件 的授权源时, 将所述文件提供给第二应用。
Table 1
Figure imgf000016_0001
Optionally, the obtaining, according to the path of the file, the file is obtained from the file system of the first application, and the providing the file to the second application may include: searching for the file in the filesyetem according to the path of the file. After finding the file, matching the source of the second application with the creation source of the file and the authorization source, and providing the file when determining that the source of the second application is the authorization source of the file Give the second application.
其中, 浏览器可以先判断请求源 (即第二应用的源) 与创建源是否同 源, 若不同源, 再判断请求源是否为授权源, 也可以两者同时判断, 具体 的判断顺序在本发明实施例中不做限定。  The browser may first determine whether the source of the request (ie, the source of the second application) is the same as the source of the creation. If the source is different, and then determine whether the source is the authorized source, the two may simultaneously determine the specific judgment sequence. The embodiment of the invention is not limited.
可选的, 在指定授权源时, 还可以进一步指定授权源的权限。 具体的, 可将用于指定授权源的字段 "DOMString Pemissions" 表示为 "权限: 授 权源"。 其中, 权限可以为: access: 可以操作文件, 如上传服务器、 修改等; Optionally, when you specify an authorization source, you can further specify the authority of the authorization source. Specifically, the field "DOMString Pemissions" for specifying the authorization source can be expressed as "permission: authorization source". Among them, the permissions can be: Access: can operate files, such as uploading servers, modifying, etc.
read: 只能读取文件;  Read: can only read files;
以扩展的 getFile 为例, 指定授权源权限时, 可表示为 getFile ( "/BenPicture/Ben. jpg", "read: *. drawing, com" );表示 *. drawing, com 可以获取文件 /BenPicture/Ben. jpg, 但仅能读取文件, 不能做修改。  Take the extended getFile as an example. When specifying the authorization source permission, it can be expressed as getFile ( "/BenPicture/Ben. jpg", "read: *. drawing, com" ); indicating *. drawing, com can get the file /BenPicture/ Ben. jpg, but only the file can be read and cannot be modified.
本发明实施例通过为文件指定授权源, 使得只有授权源的应用才可获 取该文件, 增加了在跨源访问过程中的安全性。  The embodiment of the present invention increases the security in the cross-source access process by specifying an authorization source for the file so that only the application of the authorization source can obtain the file.
在釆用方式二来指示浏览器获取文件的实施例中, 步骤 104 中的接收 与第一应用不同源的第二应用触发的获取所述文件的指令包括: 接收用户 在文件选择界面中, 选择所述文件的指令。 具体的处理流程可参见图 3。  In the embodiment of the second method for instructing the browser to obtain the file, the instruction for acquiring the file triggered by the second application receiving the different source of the first application in step 104 includes: receiving the user in the file selection interface, selecting The instructions of the file. The specific processing flow can be seen in Figure 3.
图 3为釆用方式二来指示浏览器获取文件的方法流程图, 该方法包括: FIG. 3 is a flowchart of a method for instructing a browser to acquire a file by using the second method, the method includes:
S300, 浏览器接收第一应用通过该浏览器提供的第一文件系统应用编 程接口 filesystem API发起的文件保存请求。 S300. The browser receives a file save request initiated by the first application through the first file system application programming interface filesystem API provided by the browser.
S302, 根据所述文件保存请求, 将所述第一应用需保存的文件保存到 文件系统 filesystem中。  S302. Save the file to be saved by the first application to the file system filesystem according to the file save request.
步骤 S300-S302的具体实现可参考图 1所示实施例, 这里不再赘述。 For the specific implementation of the steps S300-S302, reference may be made to the embodiment shown in FIG. 1, and details are not described herein again.
S304, 浏览器接收第二应用通过 file API发起的文件获取请求, 该文 件获取请求指示浏览器釆用用户选择的方式获取文件; S304: The browser receives a file acquisition request initiated by the second application by using the file API, where the file acquisition request instructs the browser to obtain the file by using a manner selected by the user;
具体的, 第二应用可以通过浏览器提供的 file API 中的 <input type="file,,>发起文件获取请求。 其中, < input type="f i le,,>表示由用户 输入选择要获取的文件。  Specifically, the second application can initiate a file acquisition request by using <input type="file,,> in the file API provided by the browser. Wherein, < input type="fi le,,> indicates that the user input selects the content to be acquired. file.
S306, 浏览器根据该文件获取请求打开文件选择界面, 并在文件选择 界面中展现 filesystem中的可选文件。  S306. The browser opens the file selection interface according to the file acquisition request, and displays an optional file in the filesystem in the file selection interface.
浏览器在收到 <input type= "file" >后, 将 filesystem 中的文件展 现在文件选择界面中供用户选择。  After the browser receives <input type= "file" >, the file in filesystem is displayed in the file selection interface for the user to select.
需要说明的是, 在文件选择界面中除了展现 f i lesys tem中的可选文件 外, 还可展现其它系统盘, 如 C盘, D盘下的文件。 It should be noted that in addition to the optional files in the fi lesys tem, the file selection interface is displayed. In addition, you can also display other system disks, such as C drive, D drive files.
S308, 接收用户在文件选择界面中, 选择第一应用保存的文件的指令。 用户可以通过点击等操作在文件选择界面中选择文件, 当用户选择第 一应用保存的文件时, 浏览器可以接收由该操作触发的选择的指令, 并通 过在该指令中携带文件的路径来指示用户要选择的文件。  S308. Receive an instruction that the user selects a file saved by the first application in the file selection interface. The user can select a file in the file selection interface by clicking and the like. When the user selects the file saved by the first application, the browser can receive the selected instruction triggered by the operation, and indicate by the path carrying the file in the instruction. The file the user wants to select.
S310,获取所述文件的路径,并根据所述文件的路径从所述 f i 1 e s y s t em 中获取所述文件, 将所述文件给第二应用。  S310. Obtain a path of the file, and obtain the file from the f i 1 e s y s t em according to the path of the file, and send the file to a second application.
由于在一些釆用大文件存储方式的 filesystem中, 文件只有浏览器可 见, 用户通过文件选择界面看到的文件不是独立的单文件形式, 从而无法 由用户通过文件选择界面进行文件选择。  In some filesystems that use large file storage methods, the files are only visible to the browser. The files that the user sees through the file selection interface are not in a single file format, so the user cannot select files through the file selection interface.
因此, 在本发明另一实施例中, 浏览器可以将 filesystem中的文件以 虚拟文件的形式展现给用户选择。 具体的, 步骤 306 中的在文件选择界面 中展现 filesystem中的可选文件包括: 浏览器确定 filesystem中可被第 二应用获取的可选文件, 为每个可选文件生成一个关联的虚拟文件, 以所 述可选文件的路径作为与所述虚拟文件关联的信息, 并将生成的虚拟文件 展现在文件选择界面中, 以便所述用户通过虚拟文件来选择与该虚拟文件 关联的文件。 其中, 浏览器在生成虚拟文件时将该文件的路径附给虚拟文 件, 以将该虚拟文件关联到对应的可选文件。  Therefore, in another embodiment of the present invention, the browser can present the files in the filesystem to the user selection in the form of virtual files. Specifically, the displaying the optional file in the filesystem in the file selection interface in the step 306 includes: the browser determining an optional file in the filesystem that can be obtained by the second application, and generating an associated virtual file for each optional file, Taking the path of the optional file as information associated with the virtual file, and presenting the generated virtual file in a file selection interface, so that the user selects a file associated with the virtual file through the virtual file. The browser attaches the path of the file to the virtual file when the virtual file is generated, to associate the virtual file with the corresponding optional file.
本发明实施例通过为每个可选的文件生成一个虚拟文件展现给用户, 使得用户选择一个虚拟文件就可以关联到一个独立的单文件, 从而在大文 件存储方式的 filesystem中实现了釆用用户选择文件方式的跨源访问。  In the embodiment of the present invention, a virtual file is generated for each optional file and displayed to the user, so that the user selects a virtual file to be associated with a separate single file, thereby implementing the user in the filesystem of the large file storage mode. Select cross-source access for file mode.
需要说明的是, 在安全性要求不高的系统中, filesystem中可被第二 应用获取的可选文件可以是 filesystem中的所有文件。  It should be noted that in a system with low security requirements, an optional file that can be obtained by the second application in the filesystem may be all files in the filesystem.
可选的, 为了增加在跨源访问过程中的安全性, 也可对 filesystem中 的文件的访问权限做控制。 可以允许第一应用指定授权源, 其它源只有在 第一应用指定的授权源中才可获取第一应用保存的文件。 filesystem中可 被第二应用获取的可选文件可以只包括被授权可以获取的文件。 具体的, 在 S304之前还可以包括: 记录所述文件的创建源, 所述创建源为保存所述 文件的第一应用的源; 接收所述第一应用指定的所述文件的授权源, 所述 授权源为被授权可以获取所述文件的源; 记录所述文件的授权源, 所述文 件的授权源中包括所述第二应用的源。 其中, 第一应用指定授权源的方式 可参考图 2 所示的实施例, 浏览器记录创建源和授权源的方式也可以参考 图 2所示实施例中的表 1, 这里不再赘述。 Optionally, in order to increase security during cross-origin access, you can also control access to files in filesystem. The first application may be allowed to specify an authorization source, and other sources may acquire the file saved by the first application only in the authorization source specified by the first application. Filesystem The optional file obtained by the second application may only include files that are authorized to be obtained. Specifically, before S304, the method further includes: recording a creation source of the file, where the creation source is a source of the first application that saves the file; and receiving an authorization source of the file specified by the first application, where The authorization source is a source that is authorized to obtain the file; an authorization source of the file is recorded, and an authorization source of the file includes a source of the second application. For the manner in which the first application specifies the authorization source, refer to the embodiment shown in FIG. 2. The manner in which the browser records the creation source and the authorization source may also refer to Table 1 in the embodiment shown in FIG. 2, and details are not described herein again.
相应的, 浏览器确定 filesystem中可被第二应用获取的可选文件具体 包括: 将创建源包括所述第二应用的源的文件, 以及授权源包括所述第二 应用的源的文件确定为 filesystem中可被所述第二应用获取的可选文件。  Correspondingly, the browser determines that the optional file that can be obtained by the second application in the filesystem comprises: a file that creates a source including the source of the second application, and a file whose source of authorization includes the source of the second application is determined as An optional file in the filesystem that can be obtained by the second application.
为了提高文件选择界面的易操作性, 本发明实施例还可以在文件选择 界面中进行分层展现。 具体的, 在文件选择界面中展现可选文件前, 还包 括: 生成 filesystem虚拟文件夹, 并将该 f i lesys tem虚拟文件夹作为系 统盘展现在文件选择界面中, 在接收到用户选择该 filesystem虚拟文件夹 的操作后执行所述在文件选择界面中展现可选文件的操作。  In order to improve the operability of the file selection interface, the embodiment of the present invention can also perform hierarchical presentation in the file selection interface. Specifically, before the optional file is displayed in the file selection interface, the method further includes: generating a filesystem virtual folder, and displaying the virtual thread virtual folder as a system disk in the file selection interface, and receiving the filesystem virtual The operation of presenting the optional file in the file selection interface is performed after the operation of the folder.
例如, 浏览器可将 filesystem虚拟文件夹作为系统盘与 C盘, D盘等 一起展现, 当检测到用户点击 filesystem 虚拟文件夹的操作时, 确定 filesystem中可被第二应用获取的可选文件, 并生成对应虚拟文件, 将生 成的虚拟文件作为 f i 1 e s y s t em虚拟文件夹中的子文件展现。  For example, the browser can display the filesystem virtual folder as a system disk together with the C disk, the D disk, and the like. When detecting the operation of the user clicking the filesystem virtual folder, the executable file that can be obtained by the second application in the filesystem is determined. And generate a corresponding virtual file, and the generated virtual file is displayed as a subfile in the fi 1 esyst em virtual folder.
为了更进一步提高文件选择界面的易操作性, 本发明实施例不仅可以 展现 filesystem虚拟文件夹层, 还可以展现创建源层, 创建源主机层等多 个层次。 以展现创建源层为例, 浏览器在确定出可选文件时, 还包括: 确 定可选文件的创建源, 分别生成各创建源的虚拟文件夹。 其中, 将生成的 虚拟文件展现在文件选择界面中具体包括: 将创建源的虚拟文件夹作为 filesystem虚拟文件夹中的子文件夹, 并将可选文件的虚拟文件放在对应 的创建源的虚拟文件夹中, 作为创建源虚拟文件夹的子文件展现。 需要说 明的是, 本实施例需要预先记录文件对应的创建源, 具体的可在步骤 302 中浏览器保存文件的时候记录该文件的创建源。 In order to further improve the operability of the file selection interface, the embodiment of the present invention can not only display the filesystem virtual folder layer, but also display multiple layers such as creating a source layer and creating a source host layer. For example, when the display source layer is determined, the browser further includes: determining the creation source of the optional file, and respectively generating the virtual folder of each creation source. The displaying the generated virtual file in the file selection interface specifically includes: creating a virtual folder of the source as a subfolder in the filesystem virtual folder, and placing the virtual file of the optional file in the virtual of the corresponding creation source. In the folder, as a subfile of the creation source virtual folder. Need to say It is to be noted that, in this embodiment, the creation source corresponding to the file needs to be recorded in advance, and specifically, the creation source of the file may be recorded when the browser saves the file in step 302.
下面在图 4和图 5中结合具体的应用场景对本发明实施例的方案做更 进一步 的说明 。 4艮设应 用 场 景如下 : 用 户 在照相 网 站 hUp:〃丽 w. paizhao. com/使用 camera应用拍了张照片, 想使用处理照片 的专业网站 hup: //www. drawing, com/中的 drawing应用来对此照片进行后 期处理。 其中, 第一应用为 camera, 源为 http: //www. paizhao. com/, 第 二应用为 drawing, 源为 http: //www. drawing. com/。  The solution of the embodiment of the present invention will be further described in conjunction with the specific application scenarios in FIG. 4 and FIG. 4 The application scenario is as follows: The user takes a photo on the photo website hUp: 〃丽 w. paizhao. com/ uses the camera application, wants to use the professional website for processing photos hup: //www. drawing, drawing application in com/ To post-process this photo. The first application is camera, the source is http: //www. paizhao.com/, the second application is drawing, and the source is http: //www. drawing.com/.
图 4为在应用场景中釆用方式一来指示浏览器获取文件的方法流程图, 口图 4所示, 该方法包括:  FIG. 4 is a flowchart of a method for instructing a browser to acquire a file in an application scenario. As shown in FIG. 4, the method includes:
S400, 运行在浏览器中的 camera 应用通过该浏览器提供的第一 filesystem API发起的文件保存请求, 并在文件保存请求中指定授权源。  S400, the camera application running in the browser uses a file save request initiated by the first filesystem API provided by the browser, and specifies an authorization source in the file save request.
具体的, 浏览器运行 camera应用, 利用 camera应用的照相功能实现 拍照, 如 camera 应用可以通过调用浏览器提供的下述 API: <input type="f ile" accept=" image/*" capture="camera")^指示浏览器调用下 层操作系统接口, 与硬件(如, 摄像头)通信, 实现拍照功能。  Specifically, the browser runs the camera application, and uses the camera function of the camera application to realize the photographing. For example, the camera application can call the following API provided by the browser: <input type="f ile" accept=" image/*" capture=" Camera")^ instructs the browser to call the lower operating system interface and communicate with hardware (eg, camera) to implement the camera function.
当用户点击保存功能时, camera 应用调用浏览器提供的下述 filesystem API: f s. getFi le ( "/ camera /Mike' s head, jpg" , {create: ture} , " *. drawing, com") 发起文件保存请求给浏 览器, 其中 "/camera/Mike' s head, jpg" 为 camera应用指定的保存路径, 并作为唯 一标识该文件的标识符, "*. drawing, com"为 4受权源, "*" 为通配符, 可以 代表一个或多个字符。 fs为指向 camera应用 f i lesys tem的标识。  When the user clicks on the save function, the camera application calls the following filesystem API provided by the browser: f s. getFi le ( "/ camera /Mike' s head, jpg" , {create: ture} , " *. drawing, com" Initiating a file save request to the browser, where "/camera/Mike's head, jpg" is the save path specified for the camera application, and as an identifier that uniquely identifies the file, "*. drawing, com" is the 4 authorized source , "*" is a wildcard that can represent one or more characters. Fs is the identifier of the camera application f i lesys tem.
S402, 浏览器根据该文件保存请求, 将 camera应用需保存的文件保存 到文件系统 f i lesys tem中, 并记录该文件的创建源和 4受权源。  S402. The browser saves the file to be saved by the camera application to the file system according to the file save request, and records the creation source and the authorized source of the file.
camera应用可以予贞先通过 reques tf i lesys tem在 f i lesys tem中申请 filesystem空间, 以便将要保存的文件保存到其自身的 filesystem中。 在本实施例中 , 浏览器根据 "/ camera/Mike' s head, jpg" 在 camera 的 f ilesystem中获取文件 , 若没有该文件 , 则在 camera的 f i lesys tem中 创建该文件, 将照片数据保存到获取的文件中。 The camera application can first apply for the filesystem space in the fi lesys by reques tf i lesys, in order to save the file to be saved to its own filesystem. In this embodiment, the browser obtains a file in the camera's system based on "/camera/Mike's head, jpg". If there is no such file, the file is created in the camera's fi lesys, and the photo data is saved. Go to the file obtained.
S404-S406, camera应用向浏览器发送定向到 drawing应用的请求, 并 将文件的保存路径通过浏览器发送给 drawing应用。  S404-S406, the camera application sends a request to the browser to the drawing application, and sends the file save path to the drawing application through the browser.
具体的, 用户可以点击 camera应用页面所显示的 "到 drawing应用去 编辑" 按钮, 即发起定向到 drawing应用的请求, 并将保存照片的文件路 径 携 带 在 该 请 求 中 。 例 如 : GET http: //www. drawing. com/?f i lesys temRetr ieve=f i lesys temname: / earner a/Mike's head, 其中 "www. drawing, com" 为 drawing 应用的主机地址, "f i lesys temRetr ieve" 指示从 f i lesystem中获取文件 , f i lesys tmename 为 fi lesys tem 的对象名称, 唯一指定一个 fi lesys tem 空间 。  Specifically, the user can click the "to draw application to edit" button displayed on the camera application page, that is, initiate a request directed to the drawing application, and carry the file path of the saved photo in the request. For example: GET http: //www. drawing. com/?fi lesys temRetr ieve=fi lesys temname: / earner a/Mike's head, where "www. drawing, com" is the host address of the drawing application, "fi lesys temRetr ieve "Instructs to get the file from fi lesystem, fi lesys tmename is the object name of fi lesys tem, and only specifies a fi lesys tem space.
"/camera/Mike's head" 为文件在 f ilesystem中的路径。 浏览器根据该请 求打开 if rame或 Tab或新窗口 , 把 www. drawing, com网站的页面力口载到其 中, 并将保存照片的文件路径传递给页面中的 drawing应用。  "/camera/Mike's head" is the path to the file in the fleetsystem. The browser opens an if rame or tab or a new window based on the request, loads the page of the www. drawing, com website, and passes the path of the saved photo to the drawing application on the page.
本实施例仅以釆用从 camera应用定向到 drawing应用为例进行说明。 在另一实施例中, 也可以不釆用从 camera应用定向到 drawing应用方式, 而是由用户自己打开 drawing应用。在浏览器运行 drawing应用后, camera 应用通过跨文档通信消息 postMessage, 将文件路径发送给 drawing应用 , 并指示 drawing应用从用户本地的 filesystem获取此文件数据。 例如: postMessage ( " f ilesystemRetrieve=f ilesystemname: /camera/Mike ' s head" , "hup: //www. drawing, com" )。  This embodiment is described by taking an example from the camera application orientation to the drawing application. In another embodiment, instead of using the camera application orientation to the drawing application mode, the drawing application is opened by the user himself. After the browser runs the drawing application, the camera application sends the file path to the drawing application via the cross-document communication message postMessage, and instructs the drawing application to retrieve the file data from the user's local filesystem. For example: postMessage ( " f ilesystemRetrieve=f ilesystemname: /camera/Mike ' s head" , "hup: //www. drawing, com" ).
S408, drawing应用根据接收到的文件路径确定需从 filesystem中获 取文件后, 调用浏览器提供的 filesystem API来获取 camera应用保存的 文件, 并将从 camera应用获取到的文件路径作为所调用的 API的参数。  S408, the drawing application determines, according to the received file path, that the file is obtained from the filesystem, and then calls the filesystem API provided by the browser to obtain the file saved by the camera application, and uses the file path obtained from the camera application as the called API. parameter.
drawing应用调用 filesystem API会向浏览器发送调用指令, 调用格 式如: f i lesys temname. getFi le ( "/ camera /Mike' s head, jpg" )。 The drawing application calls the filesystem API to send a call instruction to the browser. For example: fi lesys temname. getFi le ( "/ camera /Mike' s head, jpg" ).
S410, 浏览器判断请求源是否为文件的创建源或授权源, 若是创建源 或授权源, 则执行 S412, 将文件提供给 drawing应用; 若既不是创建源也 不是授权源, 则执行 S414, 返回获取失败响应。  S410, the browser determines whether the request source is a file creation source or an authorization source. If the source or the authorization source is created, executing S412 to provide the file to the drawing application; if neither the creation source nor the authorization source, executing S414, returning Get the failure response.
其中, 请求源为请求获取文件的应用对应的源。 浏览器在 fi lesys temname指定的 file system空间中根据文件路径 "/camera /Mike' s head, jpg" 查找预先记录的创建源和 4受权源, 确定该文件的创建源为 "http: //www. paizhao. com/" , 授权源为 drawing. com,'。 而请求获取 该文件的 drawing应用的源为" hup: //www. drawing. com〃', 因此, 执行步 骤 S412。  The request source is the source corresponding to the application requesting to obtain the file. The browser finds the pre-recorded creation source and the 4 authorized source according to the file path "/camera /Mike' s head, jpg" in the file system space specified by fi lesys temname, and determines that the file is created with the source "http: //www . paizhao. com/" , the authorized source is drawing. com, '. The source of the drawing application requesting the file is "hup: //www. drawing.com〃", and therefore, step S412 is performed.
图 5为在应用场景中釆用方式二来指示浏览器获取文件的方法流程图, 如图 5所示, 该方法包括:  FIG. 5 is a flowchart of a method for instructing a browser to acquire a file in the application scenario. As shown in FIG. 5, the method includes:
S500, 运行在浏览器中的 camera 应用通过该浏览器提供的第一 filesystem API发起的文件保存请求, 并在文件保存请求中指定授权源。  S500, the camera application running in the browser sends a file save request initiated by the first filesystem API provided by the browser, and specifies an authorization source in the file save request.
具体的可参考图 4中步骤 S400, 这里不再赘述。  For details, refer to step S400 in Figure 4, and details are not described herein.
S502, 浏览器根据该文件保存请求, 将 camera应用需保存的文件保存 到文件系统 f i lesys tem中, 并记录该文件的创建源和 4受权源。  S502. The browser saves the file to be saved by the camera application to the file system according to the file save request, and records the creation source and the authorized source of the file.
具体的可参考图 4中步骤 S400, 这里不再赘述。  For details, refer to step S400 in Figure 4, and details are not described herein.
S504, drawing应用调用浏览器提供的 file API发起文件获取请求。 例如, 用户在 drawing应用中点击 "上传文件"按钮时, drawing应用 通过 <input type= "file" >请求浏览器提供可被用户浏览选择的文件, 并 根据应用页面的输入确定待处理的文件。 这里的输入并不仅指键盘打字输 入, 而是一个广义概念, 可以是用户点击文件等输入方式。  S504. The drawing application invokes a file API provided by the browser to initiate a file acquisition request. For example, when the user clicks the "Upload File" button in the drawing application, the drawing application requests the browser to provide a file that can be browsed by the user through <input type= "file" >, and determines the file to be processed according to the input of the application page. The input here is not only a keyboard typing input, but a generalized concept, which can be a user input method such as clicking a file.
S506, 浏览器根据该文件获取请求打开文件选择界面, 并生成 filesystem虚拟文件夹,将该 fi lesys tem虚拟文件夹作为系统盘展现在文 件选择界面中。 图 6为 filesystem虚拟文件夹的显示界面示意图, 其中, "网页源" 文件夹即为 filesystem虚拟文件夹、 S506. The browser opens the file selection interface according to the file obtaining request, and generates a filesystem virtual folder, and displays the virtual thread virtual folder as a system disk in the file selection interface. Figure 6 is a schematic diagram of a display interface of a filesystem virtual folder, wherein the "web source" folder is a filesystem virtual folder,
S508, 浏览器接收用户在文件选择界面中选择该 filesystem虚拟文件 夹的操作。  S508. The browser receives an operation of selecting a filesystem virtual folder in a file selection interface.
用户在文件选择界面中点击 filesystem虚拟文件夹后, 浏览器接收该 用户的选择操作。  After the user clicks the filesystem virtual folder in the file selection interface, the browser receives the user's selection operation.
S510-516, 浏览器确定 filesystem中可被第二应用获取的可选文件以 及所述可选文件的创建源, 生成创建源文件夹以及与可选文件关联的虚拟 文件, 将创建源的虚拟文件夹作为 filesystem虚拟文件夹中的子文件夹, 并将可选文件的虚拟文件放在对应的创建源的虚拟文件夹中, 作为创建源 虚拟文件夹的子文件展现。  S510-516, the browser determines an optional file in the filesystem that can be obtained by the second application, and a creation source of the optional file, and generates a creation source folder and a virtual file associated with the optional file, and the virtual file of the source is created. The folder is a subfolder in the filesystem virtual folder, and the virtual file of the optional file is placed in the virtual folder of the corresponding creation source, and is displayed as a subfile of the creation source virtual folder.
浏览器可根据预先记录的文件的创建源和授权源, 确定可被第二应用 获取的可选文件以及可选文件的创建源。 具体的, 浏览器可以遍历 filesyste中的各文件,判断 drawing应用的源是否在此文件的创建源或授 权源中, 从而确定出可获取的文件以及该文件的创建源。  The browser can determine the optional file that can be obtained by the second application and the creation source of the optional file according to the creation source and the authorization source of the pre-recorded file. Specifically, the browser can traverse each file in the filesyste to determine whether the source of the drawing application is in the creation source or the authorization source of the file, thereby determining the available file and the creation source of the file.
在生成创建源的虚拟文件夹时, 为相同的创建源生成一个虚拟文件夹, 如图 7所示, 图 7为创建源的虚拟文件夹的展示界面示意图。  When generating the virtual folder of the creation source, a virtual folder is generated for the same creation source, as shown in FIG. 7, FIG. 7 is a schematic diagram of the display interface of the virtual folder for creating the source.
浏览器在为可选文件生成虚拟文件时, 会为每个可选文件生成一个关 联的虚拟文件, 如图 8所示, 图 8为虚拟文件的展示界面示意图。 其中, 浏览器可以先展示创建源的虚拟文件夹, 当接收到用户选择创建源的虚拟 文件夹的操作时, 再生成虚拟文件并展现。  When the browser generates a virtual file for an optional file, it generates an associated virtual file for each optional file, as shown in Figure 8. Figure 8 is a schematic diagram of the virtual file display interface. The browser may first display the virtual folder of the creation source, and when receiving the operation of selecting the virtual folder of the source, the virtual file is generated and displayed.
S518,接收用户选择 camera应用保存的文件所对应的虚拟文件的操作。 用户选择虚拟文件时, 该操作会将虚拟文件的关联信息发送给浏览器。 S520, 将用户选择的虚拟文件所对应的文件提供给 drawing应用。 浏览器可根据虚拟文件的关联信息 (即文件路径)获取对应的文件。 在本发明实施例中, 应用可以获取到不同源的应用的存储信息, 如, 文件路径, 克服了在基于沙盒机制的文件系统 filesystem中, 不同源的应 用保存的文件互相不可见的问题, 实现了跨源的文件获取。 S518. Receive an operation of selecting a virtual file corresponding to a file saved by the camera application. When the user selects a virtual file, the operation sends the associated information of the virtual file to the browser. S520: Provide a file corresponding to the virtual file selected by the user to the drawing application. The browser can obtain the corresponding file according to the associated information of the virtual file (ie, the file path). In the embodiment of the present invention, the application can obtain storage information of applications of different sources, for example, The file path overcomes the problem that the files saved by different source applications are invisible to each other in the file system filesystem based on the sandbox mechanism, and the cross-source file acquisition is realized.
图 9是本发明实施例提供一种获取文件的装置的示范性逻辑结构示意 图。 该装置应用于基于沙盒 sandbox机制的文件系统 f ilesystem。 如图 9 所示, 该装置包括: 接口单元 901, 请求处理单元 902, 保存单元 903, 事 件处理单元 904, 获取单元 905以及提供单元 906。  FIG. 9 is a schematic diagram showing an exemplary logical structure of an apparatus for acquiring a file according to an embodiment of the present invention. The device is applied to a file system based on the sandbox sandbox mechanism. As shown in FIG. 9, the apparatus includes: an interface unit 901, a request processing unit 902, a saving unit 903, an event processing unit 904, an obtaining unit 905, and a providing unit 906.
接口单元 901, 用于提供第一文件系统应用编程接口 filesystem API。 其中, 第一文件系统应用编程接口 filesystem API可以包括至少一个 filesystem API, 如 getFile API和 Write API。  The interface unit 901 is configured to provide a first file system application programming interface filesystem API. The first file system application programming interface filesystem API may include at least one filesystem API, such as a getFile API and a Write API.
请求处理单元 902,用于接收第一应用通过所述接口单元 901提供的第 a request processing unit 902, configured to receive a first application provided by the interface unit 901
― filesystem API发起的文件保存请求. ― Filesystem API initiated file save request.
请求处理单元 902可以通过 getFile API来获取文件入口,并通过 Wr i te API向获取的文件中写入要保存的数据。具体处理可参考图 1所示实施例的 步骤 S100, 这里不再赘述。  The request processing unit 902 can obtain the file entry through the getFile API, and write the data to be saved to the acquired file through the Wr i te API. For specific processing, reference may be made to step S100 of the embodiment shown in FIG. 1, and details are not described herein again.
需要说明的是, 如果在发起文件保存请求时, 第一应用还没有被分配 filesystem 存储空间, 第一应用在发起文件保存请求时, 还可以调用 filesystem API中的 reques tFi leSys tem API来指示浏览器为其分配一定 大小的 file system存储空间, 用来保存第一应用的文件。 第一应用在发 起分配 filesystem存储空间的请求可由请求处理单元 902。  It should be noted that, if the first application has not been allocated filesystem storage space when initiating the file save request, the first application may also invoke the reques tFi leSystem API in the filesystem API to instruct the browser when initiating the file save request. A file system storage space of a certain size is allocated for storing the file of the first application. The first application may initiate a request to allocate filesystem storage space by request processing unit 902.
保存单元 903,用于根据所述请求处理单元 902接收到的文件保存请求, 将第一应用需保存的文件保存到文件系统 f i 1 e s y s t em中。  The saving unit 903 is configured to save the file to be saved by the first application to the file system f i 1 e s y s t em according to the file saving request received by the request processing unit 902.
具体的,保存单元 903在 filesystem中找到 getFile中的 "DOMString path" 指定的文件, 并将第一应用要保存的数据写入该文件中, 写入数据 后的该文件即为第一应用保存的文件。 如果 filesystem 中不存在 "DOMString path" 指定的文件, 则创建该文件, 再将要保存的数据写入 该文件中。 事件处理单元 904,用于接收与所述第一应用不同源的第二应用触发的 获取所述第一应用保存的文件的指令, 所述指令携带所述文件的路径。 Specifically, the saving unit 903 finds the file specified by the "DOMString path" in the getFile in the filesystem, and writes the data to be saved by the first application into the file, and the file after the data is written is saved by the first application. file. If the file specified by "DOMString path" does not exist in the filesystem, create the file and write the data to be saved to the file. The event processing unit 904 is configured to receive an instruction for acquiring a file saved by the first application triggered by a second application that is different from the first application, where the instruction carries a path of the file.
获取单元 905,用于从所述事件处理单元 904接收的指令中获取所述文 件的路径, 并根据所述文件的路径从所述 filesystem中获取所述文件; 提供单元 906,用于将所述获取单元 905获取的文件提供给所述第二应 用。  An obtaining unit 905, configured to acquire a path of the file from an instruction received by the event processing unit 904, and obtain the file from the filesystem according to a path of the file; a providing unit 906, configured to: The file acquired by the obtaining unit 905 is provided to the second application.
以上各单元的具体实现均可参考方法实施例部分的说明。  For specific implementations of the above units, reference may be made to the description of the method embodiments.
在具体实现过程中, 事件处理单元 904 可通过以下两种方式接收的第 二应用触发的获取第一应用保存的文件的指令:  In a specific implementation process, the event processing unit 904 can obtain an instruction of the file saved by the first application triggered by the second application received by the following two methods:
方式一: 接收第二应用通过调用第二 filesystem API发起的获取所述 文件的指令。 釆用此方式时, 接口单元 901 还用于提供第二 filesystem API; 事件处理单元 904通过接口单元 901提供的第二 filesystem API接 收第二应用触发的获取所述文件的调用指令。  Manner 1: Receive an instruction of the second application to obtain the file by calling a second filesystem API. In this manner, the interface unit 901 is further configured to provide a second filesystem API; the event processing unit 904 receives the second application-triggered call instruction for acquiring the file through the second filesystem API provided by the interface unit 901.
方式二: 接收用户在文件选择界面中, 选择第一应用保存的文件的指 令。 釆用此方式时, 接口单元 901还用于提供 file API; 事件处理单元 904 还用于接收第二应用通过接口单元 901提供的 file API发起的文件获取请 求, 该文件获取请求指示釆用用户选择的方式获取文件。 事件处理单元 904 根据该文件获取请求打开文件选择界面, 在所述文件选择界面中展现 filesystem中的可选文件, 以便用户在文件选择界面中, 选择第一应用保 存的文件。  Manner 2: The receiving user selects an instruction of the file saved by the first application in the file selection interface. In this manner, the interface unit 901 is further configured to provide a file API; the event processing unit 904 is further configured to receive a file acquisition request initiated by the second application through the file API provided by the interface unit 901, where the file acquisition request indicates that the user selects Way to get the file. The event processing unit 904 opens a file selection interface according to the file acquisition request, and displays an optional file in the filesystem in the file selection interface, so that the user selects the file saved by the first application in the file selection interface.
需要说明的是, 无论釆用上述哪种方式, 均要由第二应用来触发。 在釆用方式一来实现本发明的实施例中, 获取文件的装置还可以包括 转发单元 1001, 如图 10所示, 图 10是本发明另一实施例提供一种获取文 件的装置的示范性逻辑结构示意图。  It should be noted that regardless of which of the above methods is used, it is triggered by the second application. In an embodiment of the present invention, the apparatus for acquiring a file may further include a forwarding unit 1001. As shown in FIG. 10, FIG. 10 is an exemplary embodiment of an apparatus for acquiring a file according to another embodiment of the present invention. Schematic diagram of the logical structure.
其中, 转发单元 1001用于接收第一应用在保存所述文件后向第二应用 发送的所述文件的路径; 并将所述文件的路径转发给第二应用, 以便第二 应用根据所述文件的路径发起调用第二 filesystem API的调用指令。 在具体实现时, 文件的路径可携带在第一应用向第二应用发送的跨文 档通信消息 postMessage 中, 或, 携带在第一应用向第二应用发送的超文 本传输协议 HTTP消息中。 详细说明可参见方法实施例中的步骤 204。 The forwarding unit 1001 is configured to receive a path of the file that is sent by the first application to the second application after saving the file, and forward the path of the file to the second application, so that the second The application initiates a call instruction to invoke the second filesystem API according to the path of the file. In a specific implementation, the path of the file may be carried in the cross-document communication message postMessage sent by the first application to the second application, or may be carried in the Hypertext Transfer Protocol (HTTP) message sent by the first application to the second application. For a detailed description, refer to step 204 in the method embodiment.
接口单元 901还用于提供第二 filesystem API。  The interface unit 901 is also used to provide a second filesystem API.
事件处理单元 904通过接口单元 901提供的第二 filesystem API接收 第二应用触发的获取所述文件的调用指令。  The event processing unit 904 receives the second application-triggered call instruction for acquiring the file through the second filesystem API provided by the interface unit 901.
可选的, 为了提高跨源访问的安全性, 请求处理单元 902还用于接收 所述第一应用指定的所述文件的授权源, 所述授权源为被授权可以获取所 述文件的源。 具体实现可参见图 2所示的方法实施例部分。  Optionally, in order to improve the security of the cross-source access, the request processing unit 902 is further configured to receive an authorization source of the file specified by the first application, where the authorization source is a source that is authorized to obtain the file. See the method embodiment section shown in Figure 2 for specific implementation.
保存单元 903, 还用于记录所述文件的创建源和所述文件的授权源, 所 述创建源为保存所述文件的第一应用的源; 所述授权源中包括所述第二应 用的源。 具体的记录方式可参考方法实施例中的表 1。  The saving unit 903 is further configured to record a creation source of the file and an authorization source of the file, where the creation source is a source of the first application that saves the file, and the authorization source includes the second application. source. For specific recording methods, refer to Table 1 in the method embodiment.
获取单元 905具体包括:  The obtaining unit 905 specifically includes:
获取子单元 1002, 用于从事件处理单元 904接收的指令中获取所述文 件的路径;  The obtaining subunit 1002 is configured to obtain a path of the file from an instruction received by the event processing unit 904;
查找子单元 1003, 用于根据所述获取子单元 1002 获取的路径, 在 filesystem中查找所述文件;  The finding subunit 1003 is configured to search for the file in the filesystem according to the path obtained by the obtaining subunit 1002.
鉴权子单元 1004, 用于在所述查找子单元 1003查找到所述文件后, 将 第二应用的源与所述文件的创建源和授权源进行匹配, 在确定第二应用的 源为所述文件的授权源时, 通知提供单元 906将所述查找模块 1003查找到 的文件发送给第二应用。  The authentication subunit 1004 is configured to: after the searching subunit 1003 finds the file, match the source of the second application with the creation source and the authorization source of the file, and determine the source of the second application as the source When the authorization source of the file is described, the notification providing unit 906 sends the file found by the searching module 1003 to the second application.
以上各功能的具体实现可参考图 1,图 2以及图 4所示方法实施例部分 的详细说明。  For a detailed implementation of the above functions, reference may be made to the detailed description of the embodiment of the method shown in FIG. 1, FIG. 2 and FIG.
上述实施例通过将第一应用保存在 filesystem中的文件的路径发送给 第二应用, 使得第二应用可以通过该路径获取到第一应用保存在 filesystem中的文件, 从而实现跨源访问。 并且通过为文件指定授权源, 使得只有授权源的应用才可获取该文件, 增加了在跨源访问过程中的安全 性。 The above embodiment sends the path of the file saved in the filesystem to the second application, so that the second application can obtain the first application by using the path. Files in filesystem for cross-source access. And by specifying an authorization source for the file, the application can be obtained only by the application of the authorization source, which increases the security in the process of cross-origin access.
在釆用方式二来实现本发明的实施例中, 在图 9所示实施例的基础上, 接口单元 901还用于提供 file API; 事件处理单元 904具体可包括接收子 单元 1101和交互子单元 1102。如图 11所示, 图 11是本发明另一实施例提 供一种获取文件的装置的示范性逻辑结构示意图。  In the embodiment of the present invention, the interface unit 901 is further configured to provide a file API. The event processing unit 904 may specifically include a receiving subunit 1101 and an interaction subunit. 1102. As shown in FIG. 11, FIG. 11 is a schematic diagram showing an exemplary logical structure of an apparatus for acquiring a file according to another embodiment of the present invention.
其中, 接收子单元 1101, 用于接收第二应用通过接口单元 901提供的 file API发起的文件获取请求, 该文件获取请求指示釆用用户选择的方式 获取文件;  The receiving subunit 1101 is configured to receive a file acquiring request initiated by the file API provided by the second application by the interface unit 901, where the file obtaining request indicates that the file is obtained by using a mode selected by the user;
交互子单元 1102,用于根据所述接收子单元 1101接收的文件获取请求 打开文件选择界面, 在文件选择界面中展现 filesystem中的可选文件, 并 接收用户在所述文件选择界面中, 选择第一应用保存的文件的指令。  The interaction sub-unit 1102 is configured to open a file selection interface according to the file acquisition request received by the receiving sub-unit 1101, display an optional file in the filesystem in the file selection interface, and receive the user in the file selection interface, select the first An instruction to apply a saved file.
本发明实施例通过为每个可选的文件生成一个虚拟文件展现给用户, 使得用户选择一个虚拟文件就可以关联到一个独立的单文件, 从而在大文 件存储方式的 filesystem中实现了釆用用户选择文件方式的跨源访问。  In the embodiment of the present invention, a virtual file is generated for each optional file and displayed to the user, so that the user selects a virtual file to be associated with a separate single file, thereby implementing the user in the filesystem of the large file storage mode. Select cross-source access for file mode.
需要说明的是, 在安全性要求不高的系统中, filesystem中可被第二 应用获取的可选文件可以是 filesystem中的所有文件。  It should be noted that in a system with low security requirements, an optional file that can be obtained by the second application in the filesystem may be all files in the filesystem.
可选的, 为了增加在跨源访问过程中的安全性, 也可对 filesystem中 的文件的访问权限做控制。 可以允许第一应用指定授权源, 其它源只有在 第一应用指定的授权源中才可获取第一应用保存的文件。 因此, 请求处理 单元 902还用于接收所述第一应用指定的所述文件的授权源, 所述授权源 为被授权可以获取所述文件的源。 具体实现可参见图 2 所示的方法实施例 部分。  Optionally, in order to increase security during cross-origin access, you can also control access to files in filesystem. The first application may be allowed to specify an authorization source, and other sources may acquire the file saved by the first application only in the authorization source specified by the first application. Therefore, the request processing unit 902 is further configured to receive an authorization source of the file specified by the first application, where the authorization source is a source that is authorized to obtain the file. The specific implementation can be seen in the method embodiment section shown in Figure 2.
保存单元 903, 还用于记录所述文件的创建源和所述文件的授权源, 所 述创建源为保存所述文件的第一应用的源; 所述授权源中包括所述第二应 用的源。 具体的记录方式可参考方法实施例中的表 1。 The saving unit 903 is further configured to record a creation source of the file and an authorization source of the file, where the creation source is a source of a first application that saves the file, and the authorization source includes the second application The source used. For specific recording methods, refer to Table 1 in the method embodiment.
本发明实施例通过为文件指定授权源, 使得只有授权源的应用才可获 取该文件, 增加了在跨源访问过程中的安全性。  The embodiment of the present invention increases the security in the cross-source access process by specifying an authorization source for the file so that only the application of the authorization source can obtain the file.
可选的 ,在将该装置用于以大文件存储方式保存文件的 f i 1 e s y s t em时, 交互子单元 1102具体可包括:  Optionally, when the device is used to save the file f i 1 e s y s t em in a large file storage manner, the interaction subunit 1102 may specifically include:
界面模块 11021, 用于根据所述接收子单元 1101接收的文件获取请求 打开文件选择界面;  The interface module 11021 is configured to open a file selection interface according to the file obtaining request received by the receiving subunit 1101;
内容模块 11022, 用于确定 filesystem中可被所述第二应用获取的可 选文件;  a content module 11022, configured to determine an optional file in the filesystem that is obtainable by the second application;
生成模块 11023,用于为内容模块 11022确定的每个可选文件生成一个 关联的虚拟文件, 以所述可选文件的路径作为与所述虚拟文件关联的信息, 展现模块 11024,用于将生成模块 11023生成的虚拟文件展现在所述界 面模块 11021 打开的文件选择界面中, 以便所述用户通过所述虚拟文件来 选择与所述虚拟文件关联的文件;  The generating module 11023 is configured to generate an associated virtual file for each optional file determined by the content module 11022, and use the path of the optional file as information associated with the virtual file, and the presentation module 11024 is configured to generate The virtual file generated by the module 11023 is displayed in a file selection interface opened by the interface module 11021, so that the user selects a file associated with the virtual file through the virtual file;
事件模块 11025, 用于接收用户在所述文件选择界面中, 选择所述第一 应用保存的文件的指令。  The event module 11025 is configured to receive an instruction that the user selects a file saved by the first application in the file selection interface.
可选的, 为了增强文件选择界面的可操作性, 生成模块 11023, 还用于 生成 filesystem虚拟文件夹;  Optionally, in order to enhance the operability of the file selection interface, the generating module 11023 is further configured to generate a filesystem virtual folder;
展现模块 11024, 还用于将所述生成子模块 11023生成的 filesystem 虚拟文件夹作为系统盘展现在所述文件选择界面中;  The presentation module 11024 is further configured to display the filesystem virtual folder generated by the generating submodule 11023 as a system disk in the file selection interface;
事件模块 11025, 还用于接收用户选择所述 filesystem虚拟文件夹的 操作, 并在接收到所述操作后指示,展现模块 11024执行在文件选择界面中 展现 filesystem中的可选文件的操作。  The event module 11025 is further configured to receive an operation of the user selecting the filesystem virtual folder, and after receiving the operation, the presentation module 11024 performs an operation of displaying an optional file in the filesystem in the file selection interface.
可选的, 为了更进一步增强文件选择界面的可操作性, 还可以在文件 选择界面实现多层次展现, 比如还可以展现创建源层, 创建源主机层等多 个层次。 以展现创建源层为例, 内容模块 11022, 还用于确定所述可选文件 的创建源; Optionally, in order to further enhance the operability of the file selection interface, a multi-level presentation can also be implemented in the file selection interface, for example, a plurality of layers such as a source layer and a source host layer can be displayed. For example, the content creation module 11022 is further used to determine the optional file. Source of creation;
生成模块 11023,还用于分别生成内容模块 11022确定的各创建源的虚 拟文件夹;  The generating module 11023 is further configured to separately generate a virtual folder of each creation source determined by the content module 11022;
展现模块 11024具体包括:  The presentation module 11024 specifically includes:
第一展现子模块 110241 , 用于将所述生成模块 11023 生成的 filesystem虚拟文件夹作为系统盘展现在所述文件选择界面中;  a first presentation sub-module 110241, configured to display the filesystem virtual folder generated by the generating module 11023 as a system disk in the file selection interface;
第二展现子模块 110242, 用于将所述生成模块 11023生成的所述创建 源的虚拟文件夹作为所述 f i 1 e s y s t em虚拟文件夹中的子文件夹展现;  a second presentation sub-module 110242, configured to display the virtual folder of the creation source generated by the generation module 11023 as a sub-folder in the virtual folder of the f i 1 e s y s t em;
第三展现子模块 110243, 用于将所述生成模块 11023生成的所述可选 文件的虚拟文件放在对应的创建源的虚拟文件夹中, 作为所述创建源的虚 拟文件夹中的子文件展现。  a third presentation sub-module 110243, configured to place the virtual file of the optional file generated by the generating module 11023 in a virtual folder of a corresponding creation source, as a sub-file in the virtual folder of the creation source Show.
需要说明的是, 在实现多层次展现的实施例中需要预先记录文件对应 的创建源, 具体的可由保存单元 903在保存文件的时候记录该文件的创建 源。  It should be noted that, in the embodiment for implementing the multi-level presentation, the creation source corresponding to the file needs to be recorded in advance, and the storage unit 903 can record the creation source of the file when the file is saved.
以上各功能的具体实现可参考图 1,图 3以及图 5所示方法实施例部分 的详细说明。  For a detailed implementation of the above functions, reference may be made to the detailed description of the embodiment of the method shown in FIG. 1, FIG. 3 and FIG. 5.
图 9, 图 10以及图 11所记载的装置可以是包括浏览器, 并包括运行该 浏览器所需的硬件结构的装置, 该装置可以包括计算机, 平板电脑、 个人 数字助理(Personal Digital Assistant, PDA), 移动终端等。 图 12是该 装置的层次划分结构图。 其中, 该装置包括应用 1201, 浏览器 1202, 操作 系统 1203以及硬件 1204。  The device described in FIG. 9, FIG. 10 and FIG. 11 may be a device including a browser and including a hardware structure required to run the browser, and the device may include a computer, a tablet, and a personal digital assistant (PDA). ), mobile terminal, etc. Figure 12 is a hierarchical structure diagram of the apparatus. The device includes an application 1201, a browser 1202, an operating system 1203, and hardware 1204.
其中, 应用 1201为在浏览器 1202中运行的应用, 利用浏览器 1202开 放的 API来获取浏览器 1202开放的业务或设备能力,为用户提供各种业务; 应用是可以是基于 Web的, 借助浏览器来运行, 是浏览器 /服务器(即 B/S ) 架构的产物, 每个应用都有对应的 URL。  The application 1201 is an application running in the browser 1202, and uses an API opened by the browser 1202 to acquire the open service or device capability of the browser 1202, and provides various services for the user; the application may be web-based, and browsed. To run, it is the product of the browser/server (ie B/S) architecture, and each application has a corresponding URL.
浏览器 1202, 用于与操作系统通信, 通过调用操作系统提供的 API获 得下层硬件的能力; 并为运行在浏览器 1202中的应用 1201运行提供环境; 操作系统: 含硬件驱动器, 与硬件通信, 接收和处理由硬件产生的输 入信号; The browser 1202 is configured to communicate with an operating system and obtain an API provided by an operating system. The ability to get the underlying hardware; and provide an environment for the application 1201 running in the browser 1202; operating system: including a hardware driver, communicating with the hardware, receiving and processing input signals generated by the hardware;
硬件: 可以包括如处理器、 存储器、 通信接口等。  Hardware: Can include, for example, a processor, a memory, a communication interface, and the like.
其中, 图 13为该装置中的硬件结构示意图, 如图 13所示, 该装置可 包括处理器 1301、 存储器 1302、 通信接口 1303和总线 1304。 其中, 处理 器 1301、 存储器 1302和通信接口 1303通过总线 1304通信连接。  13 is a schematic diagram of a hardware structure in the apparatus. As shown in FIG. 13, the apparatus may include a processor 1301, a memory 1302, a communication interface 1303, and a bus 1304. The processor 1301, the memory 1302, and the communication interface 1303 are communicably connected by a bus 1304.
处理器 1301可以釆用通用的中央处理器 (Central Processing Unit, CPU), 处理器, 应用专用集成电路 (Application Specific Integrated Circuit, ASIC), 或者一个或多个集成电路, 用于执行相关程序, 以实现 本发明实施例所提供的技术方案,其中,浏览器可以在处理器 1301中运行, 以实现以上方法实施例和装置实施例所描述的功能。  The processor 1301 can use a general-purpose central processing unit (CPU), a processor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs, The technical solution provided by the embodiment of the present invention is implemented, wherein the browser can be run in the processor 1301 to implement the functions described in the foregoing method embodiments and device embodiments.
存储器 1302可以是只读存储器 (Read Only Memory, ROM), 静态存储 设备, 动态存储设备或者随机存取存储器(Random Access Memory, RAM )。 存储器 1302可以存储操作系统和其他应用程序。 在通过软件或者固件来实 现本发明实施例提供的技术方案时, 用于实现本发明实施例提供的技术方 案的程序代码, 如浏览器的应用程序, 保存在存储器 1302中, 并由处理器 1301来执行。  The memory 1302 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1302 can store an operating system and other applications. When the technical solution provided by the embodiment of the present invention is implemented by software or firmware, the program code for implementing the technical solution provided by the embodiment of the present invention, such as an application of a browser, is stored in the memory 1302, and is processed by the processor 1301. To execute.
通信接口 1303使用例如但不限于收发器一类的收发装置, 来实现装置 与其他设备或通信网络(例如但不限于以太网, 无线接入网(Radio Access Network, RAN), 无线局域网 (Wireless Local Area Network, WLAN)等) 之间的通信。  The communication interface 1303 implements the device with other devices or communication networks using, for example, but not limited to, transceivers such as transceivers (such as, but not limited to, Ethernet, Radio Access Network (RAN), Wireless Local Area Network (Wireless Local). Communication between Area Network, WLAN, etc.).
总线 1304可包括一通路, 在装置各个部件(例如处理器 1301、 存储器 1302和通信接口 1303 )之间传送信息。  Bus 1304 can include a path for communicating information between various components of the device, such as processor 1301, memory 1302, and communication interface 1303.
应注意, 尽管图 13所示的硬件仅仅示出了处理器 1301、 存储器 1302、 通信接口 1303以及总线 1304,但是在具体实现过程中, 本领域的技术人员 应当明白, 该装置还包含实现正常运行所必须的其他器件。 同时, 根据具 体需要, 本领域的技术人员应当明白, 还可包含实现其他功能的硬件器件。 It should be noted that although the hardware shown in FIG. 13 only shows the processor 1301, the memory 1302, the communication interface 1303, and the bus 1304, in a specific implementation process, those skilled in the art It should be understood that the device also includes other components necessary to achieve normal operation. At the same time, those skilled in the art will appreciate that hardware devices that implement other functions may also be included, depending on the particular needs.
通过以上的实施方式的描述 , 所属领域的技术人员可以清楚地了解到 本发明可以用硬件实现, 或固件实现, 或它们的组合方式来实现。 当使用 软件实现时, 可以将上述功能存储在计算机可读介质中或作为计算机可读 介质上的一个或多个指令或代码进行传输。 计算机可读介质包括计算机存 储介质和通信介质, 其中通信介质包括便于从一个地方向另一个地方传送 计算机程序的任何介质。 存储介质可以是计算机能够存取的任何可用介质。 以此为例但不限于: 计算机可读介质可以包括 RAM、 ROM, EEPR0M、 CD-ROM 或其他光盘存储、 磁盘存储介质或者其他磁存储设备、 或者能够用于携带 或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的 任何其他介质。 此外。 任何连接可以适当的成为计算机可读介质。 例如, 如果软件是使用同轴电缆、 光纤光缆、 双绞线、 数字用户线(DSL )或者诸 如红外线、 无线电和微波之类的无线技术从网站、 服务器或者其他远程源 传输的, 那么同轴电缆、 光纤光缆、 双绞线、 DSL或者诸如红外线、 无线和 微波之类的无线技术包括在所属介质的定影中。 如本发明所使用的, 盘 ( Di sk )和碟(di sc ) 包括压缩光碟(CD )、 激光碟、 光碟、 数字通用光碟 ( DVD )、 软盘和蓝光光碟, 其中盘通常磁性的复制数据, 而碟则用激光来 光学的复制数据。 上面的组合也应当包括在计算机可读介质的保护范围之 内。  From the above description of the embodiments, it will be apparent to those skilled in the art that the present invention can be implemented in hardware, or firmware implementation, or a combination thereof. When implemented in software, the functions described above may be stored in or transmitted as one or more instructions or code on a computer readable medium. Computer readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another. A storage medium may be any available media that can be accessed by a computer. By way of example and not limitation, computer readable media may comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage media or other magnetic storage device, or can be used for carrying or storing in the form of an instruction or data structure. The desired program code and any other medium that can be accessed by the computer. Also. Any connection may suitably be a computer readable medium. For example, if the software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable , fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, wireless, and microwaves are included in the fixing of the associated media. As used in the present invention, a disc (Di sk ) and a disc (di sc ) include a compact disc (CD), a laser disc, a compact disc, a digital versatile disc (DVD), a floppy disc, and a Blu-ray disc, wherein the disc is usually magnetically copied, The disc uses a laser to optically replicate the data. Combinations of the above should also be included within the scope of the computer readable media.
以上所述, 仅为本发明的具体实施例, 但本发明的保护范围并不局限 于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻 易想到变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明的 保护范围应以权利要求的保护范围为准。  The above is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims

权利要求 Rights request
1、 一种获取文件的方法, 其特征在于, 应用于基于沙盒 sandbox机制 的文件系统 f i lesys tem, 所述方法包括: 1. A method of obtaining files, which is characterized in that it is applied to a file system based on the sandbox mechanism. The method includes:
浏览器接收第一应用通过所述浏览器提供的第一文件系统应用编程接 口 f i lesys tem API发起的文件保存请求; The browser receives a file saving request initiated by the first application through the first file system application programming interface filesytem API provided by the browser;
根据所述文件保存请求, 将所述第一应用需保存的文件保存到文件系 统 f i lesys tern中; According to the file saving request, save the file to be saved by the first application into the file system filesystern;
接收与所述第一应用不同源的第二应用触发的获取所述文件的指令, 所述指令携带所述文件的路径; Receive an instruction to obtain the file triggered by a second application that is different from the first application, where the instruction carries the path of the file;
获取所述文件的路径, 并根据所述文件的路径从所述 f i lesys tem中获 取所述文件, 将所述文件提供给所述第二应用。 Obtain the path of the file, obtain the file from the filesytem according to the path of the file, and provide the file to the second application.
2、 根据权利要求 1所述的方法, 其特征在于, 还包括: 2. The method according to claim 1, further comprising:
记录所述文件的创建源, 所述创建源为保存所述文件的第一应用的源; 接收所述第一应用指定的所述文件的授权源, 所述授权源为被授权可 以获取所述文件的源; Record the creation source of the file, which is the source of the first application that saves the file; receive the authorization source of the file specified by the first application, and the authorization source is authorized to obtain the file. The source of the file;
记录所述文件的授权源, 所述授权源中包括所述第二应用的源。 The authorization source of the file is recorded, and the authorization source includes the source of the second application.
3、 根据权利要求 2所述的方法, 其特征在于, 所述根据所述文件的路 径从所述第一应用的文件系统中获取所述文件, 将所述文件提供给所述第 二应用具体包括: 3. The method according to claim 2, characterized in that: obtaining the file from the file system of the first application according to the path of the file, and providing the file to the second application. include:
根据所述文件的路径在所述 f i lesyetem中查找所述文件; Find the file in the fi lesyetem according to the path of the file;
在查找到所述文件后, 将所述第二应用的源与所述文件的创建源以及 授权源进行匹配, 在确定所述第二应用的源为所述文件的授权源时, 将所 述文件提供给所述第二应用。 After the file is found, the source of the second application is matched with the creation source and authorization source of the file. When it is determined that the source of the second application is the authorization source of the file, the source of the second application is matched with the creation source and authorization source of the file. The file is provided to the second application.
4、 根据权利要求 1-3任一项所述的方法, 其特征在于, 所述接收与所 述第一应用不同源的第二应用触发的获取所述文件的指令包括: 4. The method according to any one of claims 1 to 3, wherein the receiving an instruction to obtain the file triggered by a second application having a different source than the first application includes:
接收所述第二应用调用所述浏览器提供的第二 filesystem API来获取 所述文件的调用指令。 Receive a calling instruction for the second application to call the second filesystem API provided by the browser to obtain the file.
5、 根据权利要求 4所述的方法, 其特征在于, 还包括: 5. The method according to claim 4, further comprising:
接收所述第一应用在保存所述文件后向所述第二应用发送的所述文件 的路径; Receive the path of the file sent by the first application to the second application after saving the file;
将所述文件的路径转发给所述第二应用, 以便所述第二应用根据所述 文件的路径发起所述调用指令。 Forward the path of the file to the second application, so that the second application initiates the calling instruction according to the path of the file.
6、 根据权利要求 5所述的方法, 其特征在于, 所述文件的路径携带在 所述第一应用向第二应用发送的跨文档通信消息 postMessage 中, 或, 携 带在所述第一应用向第二应用发送的超文本传输协议 HTTP消息中。 6. The method according to claim 5, characterized in that, the path of the file is carried in the cross-document communication message postMessage sent by the first application to the second application, or, is carried in the cross-document communication message postMessage sent by the first application to the second application. In a Hypertext Transfer Protocol HTTP message sent by the second application.
7、 根据权利要求 2所述的方法, 其特征在于, 还包括: 7. The method according to claim 2, further comprising:
浏览器接收所述第二应用通过 file API发起的文件获取请求, 所述文 件获取请求指示浏览器釆用用户选择的方式获取文件; The browser receives the file acquisition request initiated by the second application through the file API, and the file acquisition request instructs the browser to obtain the file in the method selected by the user;
浏览器根据所述文件获取请求打开文件选择界面, 并在所述文件选择 界面中展现 filesystem中的可选文件; The browser opens the file selection interface according to the file acquisition request, and displays the optional files in the filesystem in the file selection interface;
所述接收与所述第一应用不同源的第二应用触发的获取所述文件的指 令包括: 接收用户在所述文件选择界面中, 选择所述文件的指令。 The receiving an instruction to obtain the file triggered by a second application that is different from the first application includes: receiving an instruction from the user to select the file in the file selection interface.
8、 根据权利要求 7所述的方法, 其特征在于, 所述在所述文件选择界 面中展现 filesystem中的可选文件包括: 8. The method according to claim 7, wherein displaying the optional files in the filesystem in the file selection interface includes:
浏览器确定 filesystem中可被所述第二应用获取的可选文件, 为每个 可选文件生成一个关联的虚拟文件, 以所述可选文件的路径作为与所述虚 拟文件关联的信息, 并将生成的虚拟文件展现在所述文件选择界面中, 以 便所述用户通过所述虚拟文件来选择与所述虚拟文件关联的文件。 The browser determines optional files in the filesystem that can be obtained by the second application, for each The optional file generates an associated virtual file, uses the path of the optional file as the information associated with the virtual file, and displays the generated virtual file in the file selection interface so that the user can Virtual File to select the file associated with the virtual file.
9、 根据权利要求 7或 8所述的方法, 其特征在于, 在所述文件选择界 面中展现 filesystem中的可选文件前, 还包括: 生成 f i lesys tem虚拟文 件夹, 并将所述 filesystem虚拟文件夹作为系统盘展现在所述文件选择界 面中, 在接收到用户选择所述 Π lesys tem虚拟文件夹的操作后执行所述在 所述文件选择界面中展现 filesystem中的可选文件的操作。 9. The method according to claim 7 or 8, characterized in that, before displaying the optional files in filesystem in the file selection interface, it further includes: generating a filesystem virtual folder, and virtualizing the filesystem The folder is displayed in the file selection interface as a system disk, and the operation of displaying the optional files in the file system in the file selection interface is performed after receiving the user's operation of selecting the UI system virtual folder.
10、 根据权利要求 9 所述的方法, 其特征在于, 所述浏览器确定 filesystem中可被所述第二应用获取的可选文件时, 还包括: 确定所述可 选文件的创建源, 并分别生成各创建源的虚拟文件夹; 10. The method according to claim 9, wherein when the browser determines the optional files in the filesystem that can be obtained by the second application, it further includes: determining the creation source of the optional files, and Generate virtual folders for each creation source respectively;
所述将生成的虚拟文件展现在所述文件选择界面中具体包括: 将所述 创建源的虚拟文件夹作为所述 filesystem虚拟文件夹中的子文件夹, 并根 将所述可选文件的虚拟文件放在对应的创建源的虚拟文件夹中, 作为所述 创建源的虚拟文件夹中的子文件展现。 Displaying the generated virtual file in the file selection interface specifically includes: using the virtual folder of the creation source as a subfolder in the filesystem virtual folder, and rooting the virtual folder of the optional file. The file is placed in the virtual folder of the corresponding creation source and displayed as a sub-file in the virtual folder of the creation source.
11、 根据权利要求 7-10任一项所述的方法, 其特征在于, 所述浏览器 确定 filesystem中可被所述第二应用获取的可选文件具体包括: 11. The method according to any one of claims 7-10, wherein the browser determines that the optional files in the filesystem that can be obtained by the second application specifically include:
将创建源包括所述第二应用的源的文件, 以及授权源包括所述第二应 用的源的文件确定为 filesystem中可被所述第二应用获取的可选文件。 A file whose creation source includes the source of the second application and a file whose authorization source includes the source of the second application are determined as optional files in the filesystem that can be obtained by the second application.
12、 一种获取文件的装置, 其特征在于, 应用于基于沙盒 sandbox机 制的文件系统 f i 1 e s y s t em , 所述装置包括: 12. A device for obtaining files, characterized in that it is applied to a file system file system based on the sandbox mechanism, and the device includes:
接口单元, 用于提供第一文件系统应用编程接口 filesystem API; 请求处理单元, 用于接收第一应用通过所述接口单元提供的第一 filesystem API发起的文件保存请求; The interface unit is used to provide a first file system application programming interface filesystem API; the request processing unit is used to receive a file saving request initiated by the first application through the first filesystem API provided by the interface unit;
保存单元, 用于根据所述请求处理单元接收到的文件保存请求, 将所 述第一应用需保存的文件保存到文件系统 f i 1 e s y s t em中; 事件处理单元, 用于接收与所述第一应用不同源的第二应用触发的获 取所述第一应用保存的文件的指令, 所述指令携带所述文件的路径; A saving unit, configured to save the files to be saved by the first application into the file system fi 1 esystem according to the file saving request received by the request processing unit; An event processing unit, configured to receive an instruction to obtain a file saved by the first application triggered by a second application that is different from the first application, where the instruction carries the path of the file;
获取单元, 用于从所述事件处理单元接收的指令中获取所述文件的路 径, 并根据所述文件的路径从所述 f i lesys tem中获取所述文件; An acquisition unit, configured to obtain the path of the file from the instruction received by the event processing unit, and obtain the file from the file system according to the path of the file;
提供单元, 用于将所述获取单元获取的文件提供给所述第二应用。 A providing unit, configured to provide the file obtained by the obtaining unit to the second application.
13、 根据权利要求 12所述的装置, 其特征在于, 所述请求处理单元, 还用于接收所述第一应用指定的所述文件的授权源, 所述授权源为被授权 可以获取所述文件的源; 13. The device according to claim 12, wherein the request processing unit is further configured to receive an authorization source of the file specified by the first application, and the authorization source is authorized to obtain the file. The source of the file;
所述保存单元, 还用于记录所述文件的创建源和所述文件的授权源, 所述创建源为保存所述文件的第一应用的源; 所述授权源中包括所述第二 应用的源。 The saving unit is also used to record the creation source of the file and the authorization source of the file. The creation source is the source of the first application that saves the file; the authorization source includes the second application. source.
14、 根据权利要求 13所述的装置, 其特征在于, 所述获取单元具体包 括: 14. The device according to claim 13, characterized in that the acquisition unit specifically includes:
获取子单元, 用于从所述事件处理单元接收的指令中获取所述文件的 路径; Obtain subunit, used to obtain the path of the file from the instruction received by the event processing unit;
查找子单元,用于根据所述获取子单元获取的路径,在所述 f i lesys tem 中查找所述文件; A search subunit is used to search for the file in the f i lesys tem according to the path obtained by the acquisition subunit;
鉴权子单元, 用于在所述查找子单元查找到所述文件后, 将所述第二 应用的源与所述文件的创建源和授权源进行匹配, 在确定所述第二应用的 源为所述文件的授权源时, 通知所述提供单元将所述查找模块查找到的文 件发送给所述第二应用。 An authentication subunit, configured to match the source of the second application with the creation source and authorization source of the file after the search subunit finds the file, and determine the source of the second application. When it is the authorized source of the file, the providing unit is notified to send the file found by the search module to the second application.
15、 根据权利要求 12-14任一项所述的装置, 其特征在于, 所述接口 单元还用于提供第二 f i lesys tem API接口; 15. The device according to any one of claims 12 to 14, characterized in that the interface unit is also used to provide a second file system API interface;
所述事件处理单元通过所述接口单元提供的第二 f i lesys tem API接收 所述第二应用触发的获取所述文件的调用指令。 The event processing unit receives the calling instruction for obtaining the file triggered by the second application through the second filesystem API provided by the interface unit.
16、 根据权利要求 15所述的装置, 其特征在于, 还包括: 转发单元, 用于接收所述第一应用在保存所述文件后向所述第二应用 发送的所述文件的路径; 并将所述文件的路径转发给所述第二应用, 以便 所述第二应用根据所述文件的路径发起所述调用指令。 16. The device according to claim 15, further comprising: A forwarding unit configured to receive the path of the file sent by the first application to the second application after saving the file; and forward the path of the file to the second application so that the third application The second application initiates the calling instruction according to the path of the file.
17、 根据权利要求 16所述的装置, 其特征在于, 所述文件的路径携带 在所述第一应用向第二应用发送的跨文档通信消息 pos tMes sage 中, 或, 携带在所述第一应用向第二应用发送的超文本传输协议 HTTP消息中。 17. The device according to claim 16, wherein the path of the file is carried in the cross-document communication message postMessage sent by the first application to the second application, or, is carried in the first application. In a Hypertext Transfer Protocol HTTP message sent by the application to the second application.
18、 根据权利要求 13所述的装置, 其特征在于, 所述接口单元, 还用 于提供 f i le API ; 18. The device according to claim 13, characterized in that the interface unit is also used to provide file API;
所述事件处理单元具体包括: The event processing unit specifically includes:
接收子单元,用于接收所述第二应用通过所述接口单元提供的 f i le API 发起的文件获取请求, 所述文件获取请求指示釆用用户选择的方式获取文 件; A receiving subunit, configured to receive a file acquisition request initiated by the second application through the file API provided by the interface unit, where the file acquisition request indicates that the file is acquired in a manner selected by the user;
交互子单元, 用于根据所述接收子单元接收的文件获取请求打开文件 选择界面, 在所述文件选择界面中展现 f i lesys tem中的可选文件, 并接收 用户在所述文件选择界面中, 选择所述第一应用保存的文件的指令。 The interactive subunit is configured to open a file selection interface according to the file acquisition request received by the receiving subunit, display the optional files in the filesytem in the file selection interface, and receive the user's request in the file selection interface, Instructions for selecting a file saved by the first application.
19、 根据权利要求 18所述的装置, 其特征在于, 所述交互子单元具体 包括: 19. The device according to claim 18, characterized in that the interactive subunit specifically includes:
界面模块, 用于根据所述接收子单元接收的文件获取请求打开文件选 择界面; Interface module, used to open the file selection interface according to the file acquisition request received by the receiving subunit;
内容模块,用于确定 f i lesys tem中可被所述第二应用获取的可选文件; 生成模块, 用于为内容模块确定的每个可选文件生成一个关联的虚拟 文件, 以所述可选文件的路径作为与所述虚拟文件关联的信息, The content module is used to determine the optional files in the filesytem that can be obtained by the second application; the generation module is used to generate an associated virtual file for each optional file determined by the content module. The path to the file as information associated with said virtual file,
展现模块, 用于将生成模块生成的虚拟文件展现在所述界面模块打开 的文件选择界面中, 以便所述用户通过所述虚拟文件来选择与所述虚拟文 件关联的文件; A presentation module, configured to present the virtual file generated by the generation module in the file selection interface opened by the interface module, so that the user can select the file associated with the virtual file through the virtual file;
事件模块, 用于接收用户在所述文件选择界面中, 选择所述第一应用 保存的文件的指令。 An event module, configured to receive the user's selection of the first application in the file selection interface. Instructions for saving files.
20、 根据权利要求 19或 19所述的装置, 其特征在于, 所述生成模块, 还用于生成 f ilesystem虚拟文件夹; 20. The device according to claim 19 or 19, characterized in that the generation module is also used to generate a filesystem virtual folder;
所述展现模块, 还用于将所述生成子模块生成的 filesystem虚拟文件 夹作为系统盘展现在所述文件选择界面中; The presentation module is also configured to present the filesystem virtual folder generated by the generation sub-module as a system disk in the file selection interface;
所述事件模块还用于接收用户选择所述 filesystem虚拟文件夹的操 作, 并在接收到所述操作后指示所述展现模块执行所述在所述文件选择界 面中展现 filesystem中的可选文件的操作。 The event module is also configured to receive an operation of the user selecting the filesystem virtual folder, and after receiving the operation, instruct the presentation module to perform the process of presenting optional files in the filesystem in the file selection interface. operate.
21、 根据权利要求 20所述的装置, 其特征在于, 所述内容模块, 还用 于确定所述可选文件的创建源; 21. The device according to claim 20, wherein the content module is also used to determine the creation source of the optional file;
所述生成模块, 还用于分别生成所述内容模块确定的各创建源的虚拟 文件夹; The generation module is also configured to respectively generate virtual folders for each creation source determined by the content module;
所述展现模块具体包括: The presentation module specifically includes:
第一展现子模块, 用于将所述生成模块生成的 filesystem虚拟文件夹 作为系统盘展现在所述文件选择界面中; The first display sub-module is used to display the filesystem virtual folder generated by the generation module as a system disk in the file selection interface;
第二展现子模块, 用于将所述生成模块生成的所述创建源的虚拟文件 夹作为所述 filesystem虚拟文件夹中的子文件夹展现; The second display sub-module is used to display the virtual folder of the creation source generated by the generation module as a sub-folder in the filesystem virtual folder;
第三展现子模块, 用于将所述生成模块生成的所述可选文件的虚拟文 件放在对应的创建源的虚拟文件夹中, 作为所述创建源的虚拟文件夹中的 子文件展现。 The third presentation sub-module is used to place the virtual file of the optional file generated by the generation module in the corresponding virtual folder of the creation source, and display it as a sub-file in the virtual folder of the creation source.
22、 根据权利要求 19-21 任一项所述的装置, 其特征在于, 所述 filesystem中可被所述第二应用获取的可选文件包括: 创建源包括所述第 二应用的源的文件, 以及授权源包括所述第二应用的源的文件。 22. The device according to any one of claims 19 to 21, wherein the optional files in the filesystem that can be obtained by the second application include: a file whose creation source includes the source of the second application. , and the authorized source includes a file of the source of the second application.
PCT/CN2012/088091 2012-12-31 2012-12-31 Method and device for obtaining file WO2014101208A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201280003352.1A CN104137073B (en) 2012-12-31 2012-12-31 A kind of method and apparatus for obtaining file
PCT/CN2012/088091 WO2014101208A1 (en) 2012-12-31 2012-12-31 Method and device for obtaining file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2012/088091 WO2014101208A1 (en) 2012-12-31 2012-12-31 Method and device for obtaining file

Publications (1)

Publication Number Publication Date
WO2014101208A1 true WO2014101208A1 (en) 2014-07-03

Family

ID=51019803

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/088091 WO2014101208A1 (en) 2012-12-31 2012-12-31 Method and device for obtaining file

Country Status (2)

Country Link
CN (1) CN104137073B (en)
WO (1) WO2014101208A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9967210B2 (en) * 2015-11-17 2018-05-08 Juniper Networks, Inc. Network device data plane sandboxes for third-party controlled packet forwarding paths
CN109672710B (en) * 2017-10-17 2022-09-13 阿里巴巴集团控股有限公司 File uploading method, system and equipment
CN111897772B (en) * 2020-08-05 2024-02-20 光大兴陇信托有限责任公司 Large file data importing method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1894667A (en) * 2003-12-18 2007-01-10 康泰克创新公司 System and method for allocating server resources
CN101515241A (en) * 2009-02-19 2009-08-26 北京安高科技有限公司 Intertask data communication control method and system
CN102473171A (en) * 2009-07-20 2012-05-23 费斯布克公司 Communicating information about a local machine to a browser application

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050091658A1 (en) * 2003-10-24 2005-04-28 Microsoft Corporation Operating system resource protection
US20100146523A1 (en) * 2008-12-05 2010-06-10 Tripod Ventures Inc./ Entreprises Tripod Inc. Browser environment application and local file server application system
US8850572B2 (en) * 2010-01-15 2014-09-30 Apple Inc. Methods for handling a file associated with a program in a restricted program environment
US9052919B2 (en) * 2010-01-15 2015-06-09 Apple Inc. Specialized network fileserver
US8819586B2 (en) * 2011-05-27 2014-08-26 Microsoft Corporation File access with different file hosts

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1894667A (en) * 2003-12-18 2007-01-10 康泰克创新公司 System and method for allocating server resources
CN101515241A (en) * 2009-02-19 2009-08-26 北京安高科技有限公司 Intertask data communication control method and system
CN102473171A (en) * 2009-07-20 2012-05-23 费斯布克公司 Communicating information about a local machine to a browser application

Also Published As

Publication number Publication date
CN104137073B (en) 2017-11-21
CN104137073A (en) 2014-11-05

Similar Documents

Publication Publication Date Title
JP5939525B2 (en) Shared service
US8677502B2 (en) Proximity based networked media file sharing
KR102121626B1 (en) Associating a file type with an application in a network storage service
US20140351211A1 (en) Media File Synchronization
CN110321733B (en) Sharing content with license control using near field communication
JP6298197B2 (en) Access to supplemental data based on identifiers derived from corresponding primary application data
JP5799259B2 (en) Electronic equipment and computer program
WO2014075478A1 (en) Resource sharing method, apparatus, system, and terminal, and resource management center
JP2016529599A (en) Content clipboard synchronization
JP5932982B2 (en) File access by multiple different file hosts
US9680885B2 (en) Information processing apparatus and terminal device that communicate with each other
WO2022143081A1 (en) Data synchronization method and apparatus
TW201903604A (en) System and method for application navigation
WO2014101208A1 (en) Method and device for obtaining file
WO2023246723A1 (en) Object access method and apparatus, and electronic device, storage medium and program product
JP6004454B2 (en) Apparatus and method for controlling access to database
JP2014044551A (en) Content acquisition device, content acquisition system, content acquisition method and content acquisition program for terminal
US20150244770A1 (en) Photo media playing method and photo media playing system for playing photo media file of social networking site in area network
KR101490688B1 (en) Apparatus for storing and processing contents and method of transmitting object meta information about contents using media transfer protocol from the apparatus
US9323777B1 (en) Distributed file-sharing across personal devices
CN117828672B (en) Fine-grained dynamic authorized access control and high concurrency processing method and device
WO2024046184A1 (en) File management and application management method, and electronic device
WO2022020265A1 (en) File interface to dynamically manage access to remote files
KR20150049493A (en) Method for converting document, and server applied to the same

Legal Events

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

Ref document number: 12890926

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12890926

Country of ref document: EP

Kind code of ref document: A1