cordova-plugin-file
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -22,7 +22,7 @@ <!--- | ||
Diese Notizen sollen in erster Linie für Android und iOS-Entwickler, die Plugins welche Schnittstelle mit dem Dateisystem, mit dem Datei-Plugin schreiben möchten. | ||
Diese Notizen sind hauptsächlich für Android und iOS-Entwickler, die Plugins welche Schnittstelle mit dem Dateisystem, mit dem Plugin Datei schreiben möchten. | ||
## Arbeiten mit Cordova-Datei-System-URLs | ||
Seit der Version 1.0.0, wurde dieses Plugin URLs mit verwendet eine `cdvfile` Regelung für die gesamte Kommunikation über die Brücke, sondern als raw-Device Dateisystempfade zu JavaScript auszusetzen. | ||
Seit der Version 1.0.0, wurde dieses Plugin verwendet URLs mit einer `cdvfile` Regelung für die gesamte Kommunikation über die Brücke, sondern als raw-Device Dateisystempfade zu JavaScript auszusetzen. | ||
@@ -33,16 +33,13 @@ Auf der Seite JavaScript bedeutet dies, dass FileEntries und DirectoryEntry-Objekt ein FullPath-Attribut haben, die relativ zum Stammverzeichnis des Dateisystems HTML ist. Wenn Ihr Plugins-JavaScript-API ein FileEntries oder DirectoryEntry-Objekt akzeptiert, rufen Sie `.toURL()` auf das Objekt vor der Übergabe an systemeigenen Code über die Brücke. | ||
Plugins, die auf das Dateisystem schreiben müssen, möchten möglicherweise eine empfangene Datei-System-URL auf eine tatsächliche Stelle des Dateisystems zu konvertieren. Es gibt mehrere Wege, dies zu tun, je nach einheitlichen Plattform. | ||
Plugins, die auf das Dateisystem schreiben müssen, sollten eine empfangene Datei-System-URL auf eine tatsächliche Stelle des Dateisystems zu konvertieren. Es gibt mehrere Wege, dies zu tun, je nach einheitlichen Plattform. | ||
Es ist wichtig zu erinnern, dass nicht alle `cdvfile://` URLs sind zuweisbaren real Dateien auf das Gerät. Einige URLs verweisen auf Vermögenswerte auf Gerät die werden nicht durch Dateien dargestellt, oder sogar auf Remoteressourcen verweisen kann. Aufgrund dieser Möglichkeiten sollten Plugins immer testen, ob sie ein sinnvolles Ergebnis zu erhalten, wieder beim URLs in Pfade umwandeln. | ||
Es ist wichtig, daran erinnern, dass nicht alle `cdvfile://` URLs sind zuweisbaren real Dateien auf das Gerät. Einige URLs verweisen auf Vermögenswerte auf Gerät nicht durch Dateien dargestellt werden, oder sogar auf Remoteressourcen verweisen können. Aufgrund dieser Möglichkeiten sollten Plugins immer testen, ob sie ein sinnvolles Ergebnis zu erhalten, wieder bei dem Versuch, die URLs in Pfade umwandeln. | ||
#### Android | ||
Auf Android, die einfachste Methode zum Konvertieren eines `cdvfile://` darin, dass die URL zu einem Dateisystempfad verwenden `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`verfügt über mehrere Methoden der verarbeiten kann `cdvfile://` URLs: | ||
Auf Android, konvertiert die einfachste Methode eine `cdvfile://` URL zu einem Dateisystempfad zu verwenden ist `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`verfügt über mehrere Methoden der verarbeiten kann `cdvfile://` URLs: | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
WebView ist Mitglied der Plugin-Klasse CordovaResourceApi ResourceApi = webView.getResourceApi(); | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
Erhalten eine file:/// URL, diese Datei auf dem Gerät / / oder die gleiche URL unverändert, wenn es eine Datei-Uri FileURL zugeordnet werden kann nicht = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
@@ -52,26 +49,18 @@ | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
Import org.apache.cordova.file.FileUtils; | ||
Import org.apache.cordova.file.FileSystem; | ||
Import Java.net.MalformedURLException:; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
Erhalten Sie das Datei-Plugin aus dem Plugin-Manager FileUtils FilePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
Angesichts eine URL, einen Pfad zu erhalten, denn es versuchen {String Pfad = filePlugin.filesystemPathForURL(cdvfileURL);} catch (MalformedURLException e) {/ / die Dateisystem-Url war nicht erkannt} | ||
Konvertieren von einen Pfad zu einer `cdvfile://` URL: | ||
Aus einem Pfad zu konvertieren eine `cdvfile://` URL: | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
Import org.apache.cordova.file.LocalFilesystemURL; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
Rufen Sie ein LocalFilesystemURL-Objekt für einen Gerätepfad / / oder null, wenn sie nicht als URL Cdvfile dargestellt wird. | ||
LocalFilesystemURL Url = filePlugin.filesystemURLforLocalPath(path); | ||
Erhalten Sie die Zeichenfolgendarstellung der URL Objekt String CdvfileURL = url.toString(); | ||
@@ -81,5 +70,4 @@ | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
Zurückgeben eine JSON-Struktur geeignet für die Rückgabe an JavaScript, / / oder null, wenn diese Datei nicht als URL Cdvfile darstellbar ist. | ||
JSONObject Eintrag = filePlugin.getEntryForFile(file); | ||
@@ -91,13 +79,9 @@ | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
Rufen Sie ein CDVFilesystem URL-Objekt von einer URL-Zeichenfolge CDVFilesystemURL * Url = [CDVFilesystemURL FileSystemURLWithString:cdvfileURL]; | ||
Erhalten Sie einen Pfad für die URL-Objekt oder NULL, wenn es einen Dateipfad NSString * zugeordnet werden kann nicht = [FilePlugin FilesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
Eine CDVFilesystem URL-Objekt für einen Gerätepfad abrufen oder / / gleich NULL, wenn sie nicht als URL Cdvfile dargestellt wird. | ||
CDVFilesystemURL-Url = [FilePlugin FileSystemURLforLocalPath:path]; | ||
Erhalten Sie die Zeichenfolgendarstellung der URL Objekt NSString * CdvfileURL = [Url AbsoluteString]; | ||
@@ -107,7 +91,5 @@ | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
Eine CDVFilesystem URL-Objekt für einen Gerätepfad abrufen oder / / gleich NULL, wenn sie nicht als URL Cdvfile dargestellt wird. | ||
CDVFilesystemURL-Url = [FilePlugin FileSystemURLforLocalPath:path]; | ||
Erhalten eine Struktur zurück nach JavaScript NSDictionary * Eintrag = [FilePlugin MakeEntryForLocalURL:url] | ||
@@ -119,13 +101,8 @@ | ||
var cdvfileURL = entry.toURL(); | ||
Var CdvfileURL = entry.toURL(); | ||
Im Plugin Antwort Handler um aus einer zurückgegebenen FileEntries-Struktur in ein tatsächliches Entry-Objekt zu konvertieren sollte Handlercode importieren die Datei-Erweiterung und ein neues Objekt erstellen: | ||
Im Plugin Antwort Handler zur Konvertierung von einer zurückgegebenen FileEntries-Struktur in einem tatsächlichen Eintrag-Objekt sollte Handlercode importieren die Datei-Erweiterung und ein neues Objekt zu erstellen: | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
Erstellen Sie entsprechenden Eintrag Objekt Var Eintrag; | ||
Wenn (entryStruct.isDirectory) {Eintrag = neues DirectoryEntry (entryStruct.name, entryStruct.fullPath, neue FileSystem(entryStruct.filesystemName));} sonst {Eintrag = neue FileEntries (entryStruct.name, entryStruct.fullPath, neue FileSystem(entryStruct.filesystemName));} |
@@ -20,63 +20,51 @@ <!--- | ||
# Notas para los desarrolladores de plugin | ||
# Notas para los desarrolladores del plugin | ||
Estas notas están pensadas principalmente para los desarrolladores de Android y el iOS que quieran escribir plugins que interfaz con el sistema de archivos usando el plugin de archivo. | ||
Estas notas están pensadas principalmente para desarrolladores de Android y el iOS que quieran escribir plugins que interfaz con el sistema de ficheros usando el plugin del archivo. | ||
## Trabajando con Cordova archivo sistema URLs | ||
## Trabajar con URLs de sistema de archivo de Córdoba | ||
Desde la versión 1.0.0, este plugin utiliza las direcciones URL con un `cdvfile` plan para todas las comunicaciones sobre el puente, en lugar de exponer rutas de sistema de archivo de dispositivo raw a JavaScript. | ||
Desde la versión 1.0.0, este plugin ha utilizado las direcciones URL con un `cdvfile` plan para todas las comunicaciones sobre el puente, en lugar de exponer rutas de sistema de archivos de dispositivos raw para JavaScript. | ||
En el lado de JavaScript, esto significa que los objetos FileEntry y DirectoryEntry tienen un atributo fullPath que es relativo a la raíz del sistema de archivos HTML. Si JavaScript API del plugin acepta un objeto FileEntry o DirectoryEntry, debe llamar a `.toURL()` en ese objeto antes de pasarla a través del puente a código nativo. | ||
En el lado de JavaScript, esto significa que los objetos FileEntry y DirectoryEntry tienen un atributo fullPath que es relativo a la raíz del sistema de archivos HTML. Si JavaScript API de tu plugin acepta un objeto FileEntry o DirectoryEntry, usted debe llamar a `.toURL()` en ese objeto antes de pasar a través del puente al código nativo. | ||
### Conversión de cdvfile: / / URL al fileystem caminos | ||
Plugins que necesita escribir en el sistema de archivos puede querer convertir un archivo recibido sistema URL a una ubicación de archivos reales. Hay varias formas de hacer esto, dependiendo de la plataforma nativa. | ||
Plugins que necesita escribir en el sistema de archivos puede convertir un archivo recibido sistema URL a una ubicación de sistema de archivos real. Hay varias formas de hacerlo, dependiendo de la plataforma nativa. | ||
Es importante recordar que no todos `cdvfile://` URLs son asignables a los archivos reales en el dispositivo. Algunas URLs pueden referirse a activos en dispositivos que no están representados por los archivos, o incluso pueden referirse a recursos remotos. Debido a estas posibilidades, plugins siempre debe probar si consiguen un resultado significativo cuando tratando de convertir URLs en trazados. | ||
Es importante recordar que no todos `cdvfile://` las direcciones URL son asignables a reales archivos en el dispositivo. Algunas URLs pueden referirse a activos en dispositivos que no están representadas por archivos, o incluso pueden hacer referencia a recursos remotos. Debido a estas posibilidades, plugins siempre debe comprobar si consiguen un resultado significativo cuando tratando de convertir las URL en trazados. | ||
#### Android | ||
En Android, el método más sencillo para convertir un `cdvfile://` URL a una ruta de sistema de archivos es utilizar `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`tiene varios métodos que pueden manejar `cdvfile://` URLs: | ||
En Android, el método más simple para convertir un `cdvfile://` URL a una ruta de sistema de archivos es utilizar `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`tiene varios métodos que pueden manejar `cdvfile://` URL: | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
webView es un miembro de la clase Plugin CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
Obtener una URL file:/// representando este archivo en el dispositivo, / / o el mismo URL sin cambios si no se puede asignar a un archivo Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
También es posible utilizar directamente el archivo plugin: | ||
También es posible utilizar el plugin de archivos directamente: | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
Import org.apache.cordova.file.FileUtils; | ||
Import org.apache.cordova.file.FileSystem; | ||
Import java.net.MalformedURLException; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
Obtener el archivo plugin desde el administrador de plugin FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
Dada una URL, haz un camino para tratar de {camino de cadena = filePlugin.filesystemPathForURL(cdvfileURL);} catch (DD e) {/ / el sistema de archivos url no reconocida} | ||
Para convertir de un camino hacia un `cdvfile://` URL: | ||
Para convertir de una ruta a un `cdvfile://` URL: | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
Import org.apache.cordova.file.LocalFilesystemURL; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
Obtener un objeto LocalFilesystemURL para una ruta, / / o null si no se puede representar como una dirección URL cdvfile. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
Obtener la representación string de la URL objeto String cdvfileURL = url.toString(); | ||
Si tu plugin crea un archivo y desea devolver un objeto FileEntry para ello, utilice el archivo plugin: | ||
Si tu plugin crea un archivo y desea devolver un objeto FileEntry para él, usar el plugin de archivos: | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
Devolver una estructura JSON adecuado para volver a JavaScript, / / o null si este archivo no es representable como una dirección URL cdvfile. | ||
JSONObject entrada = filePlugin.getEntryForFile(file); | ||
@@ -86,24 +74,18 @@ | ||
Cordova en iOS no utiliza el mismo `CordovaResourceApi` concepto como Android. En iOS, utilice el archivo plugin para convertir las direcciones URL y rutas de archivos. | ||
Cordova en iOS no utiliza la misma `CordovaResourceApi` concepto como Android. En iOS, debe usar el archivo plugin para convertir las direcciones URL y rutas de sistema de archivos. | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
Obtener un objeto URL CDVFilesystem de una URL string CDVFilesystemURL * url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
Obtener una ruta de acceso para el objeto URL, o nil si no puede ser asignado a una ruta de archivo NSString * = [filePlugin filesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
Obtener un objeto URL CDVFilesystem para una ruta, o / / nula si no se puede representar como una dirección URL cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
Obtener la representación string de la URL objetos NSString * cdvfileURL = [enlace absoluteString]; | ||
Si tu plugin crea un archivo y desea devolver un objeto FileEntry para ello, utilice el archivo plugin: | ||
Si tu plugin crea un archivo y desea devolver un objeto FileEntry para él, usar el plugin de archivos: | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
Obtener un objeto URL CDVFilesystem para una ruta, o / / nula si no se puede representar como una dirección URL cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
Conseguir una estructura para volver a JavaScript NSDictionary * entrada = [filePlugin makeEntryForLocalURL:url] | ||
@@ -113,3 +95,3 @@ | ||
En JavaScript, para conseguir un `cdvfile://` URL de un objeto FileEntry o DirectoryEntry, simplemente llame a `.toURL()` en él: | ||
En JavaScript, para obtener un `cdvfile://` dirección URL de un objeto FileEntry o DirectoryEntry, simplemente llame al `.toURL()` en él: | ||
@@ -119,10 +101,5 @@ var cdvfileURL = entry.toURL(); | ||
En plugin manipuladores de respuesta, para convertir de una estructura FileEntry devuelta a un objeto real de la entrada, el código del controlador debe importar el archivo plugin y crear un nuevo objeto: | ||
En manipuladores de la respuesta del plugin, para convertir de una estructura FileEntry devuelta a un objeto real de la entrada, su código de controlador debe importar el archivo plugin y crear un nuevo objeto: | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
crear apropiado objeto var ingreso; | ||
Si (entryStruct.isDirectory) {entrada = new DirectoryEntry (entryStruct.name, entryStruct.fullPath, FileSystem(entryStruct.filesystemName)) nuevo;} else {entrada = nuevo FileEntry (entryStruct.name, entryStruct.fullPath, nuevo FileSystem(entryStruct.filesystemName));} |
@@ -24,24 +24,21 @@ <!--- | ||
## Travaillant avec des URL de système pour le fichier Cordova | ||
## Travailler avec Cordova fichier système URL | ||
Depuis la version 1.0.0, ce plugin utilise des URL avec un `cdvfile` guichet pour toutes les communications sur le pont, plutôt que d'exposer les chemins de système de fichiers de périphérique brut à JavaScript. | ||
Depuis la version 1.0.0, ce plugin utilise des URL avec un `cdvfile` guichet pour toutes les communications sur le pont, plutôt que d'exposer des chemins de système de fichiers de périphérique brut à JavaScript. | ||
Du côté du JavaScript, cela signifie que les objets DirectoryEntry et de FileEntry ont un attribut fullPath qui est relatif à la racine du système de fichiers HTML. Si l'API JavaScript de votre plugin accepte un objet FileEntry ou DirectoryEntry, vous devez appeler `.toURL()` sur cet objet avant de le passer sur le pont en code natif. | ||
Du côté du JavaScript, cela signifie que les objets FileEntry et DirectoryEntry ont un attribut fullPath qui est relatif à la racine du système de fichiers HTML. Si votre plugin JavaScript API accepte un objet FileEntry ou DirectoryEntry, vous devez appeler `.toURL()` sur cet objet avant de le passer sur le pont en code natif. | ||
### Conversion des cdvfile: / / URL pour les chemins de fileystem | ||
### Conversion de cdvfile: / / URL aux chemins d'accès fileystem | ||
Plugins qui ont besoin d'écrire dans le système de fichiers pouvez convertir un fichier reçu système URL vers un emplacement de système de fichiers réels. Il y a plusieurs façons de le faire, selon la plate-forme native. | ||
Il est important de rappeler que pas tous les `cdvfile://` URL sont cartographiables à des fichiers sur le périphérique. Certaines URL peut faire référence aux actifs sur les périphériques qui ne sont pas représentés par des fichiers, ou peuvent même faire référence aux ressources distantes. En raison de ces possibilités, plugins devraient toujours tester si ils obtiennent un résultat significatif, retour en essayant de convertir les URL aux chemins d'accès. | ||
Il est important de rappeler que pas tous les `cdvfile://` URL sont cartographiables à des fichiers sur le périphérique. Certaines URL peut faire référence aux actifs sur les périphériques qui ne sont pas représentés par des fichiers, ou peuvent même faire référence aux ressources distantes. En raison de ces possibilités, plugins devraient toujours tester si ils obtiennent un résultat significatif retour lorsque vous essayez de convertir les URL aux chemins d'accès. | ||
#### Android | ||
#### Androïde | ||
Sur Android, la méthode la plus simple pour convertir un `cdvfile://` URL vers un chemin d'accès de système de fichiers est d'utiliser `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`comporte plusieurs méthodes qui peuvent gérer `cdvfile://` URL : | ||
Sur Android, la méthode la plus simple pour convertir un `cdvfile://` URL vers un chemin d'accès de système de fichiers est d'utiliser `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`possède plusieurs méthodes qui peuvent gérer `cdvfile://` URL : | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
webView est membre de la Plugin classe CordovaResourceApi resourceApi = webView.getResourceApi() ; | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
Obtenir une URL file:/// représentant ce fichier sur le périphérique, / / ou le même URL inchangée si elle ne peut pas être mappée à un fichier Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)) ; | ||
@@ -51,15 +48,9 @@ | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
Import org.apache.cordova.file.FileUtils ; | ||
Import org.apache.cordova.file.FileSystem ; | ||
java.net.MalformedURLException d'importation ; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
Téléchargez le fichier plugin depuis le gestionnaire de plugin FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File") ; | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
En donnant une URL, obtenir un chemin d'accès pour essayer {String path = filePlugin.filesystemPathForURL(cdvfileURL);} catch (MalformedURLException e) {/ / l'url du système de fichiers n'a pas été reconnu} | ||
@@ -69,9 +60,7 @@ | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
Import org.apache.cordova.file.LocalFilesystemURL ; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
Obtenir un objet LocalFilesystemURL pour un chemin de périphérique, / / ou null si elle ne peut être représentée sous forme d'URL cdvfile. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path) ; | ||
Obtenir la chaîne représentant l'URL objet String cdvfileURL = url.toString() ; | ||
@@ -81,5 +70,4 @@ | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
Retourne une structure JSON approprié pour revenir en JavaScript, / / ou null si ce fichier n'est pas représentable sous forme d'URL cdvfile. | ||
JSONObject entrée = filePlugin.getEntryForFile(file) ; | ||
@@ -91,13 +79,9 @@ | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
Obtenir un objet URL CDVFilesystem partir d'une chaîne d'URL CDVFilesystemURL * url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL] ; | ||
Obtenir un chemin d'accès de l'objet URL, ou zéro si elle ne peut pas être mappée à un chemin de fichier NSString * = [filePlugin filesystemPathForURL:url] ; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
Obtenir un objet CDVFilesystem URL pour un chemin de périphérique, ou / / zéro si elle ne peut être représentée sous forme d'URL cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path] ; | ||
Obtenir la représentation de chaîne de l'objet NSString * cdvfileURL URL = [url absoluteString] ; | ||
@@ -107,7 +91,5 @@ | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
Obtenir un objet CDVFilesystem URL pour un chemin de périphérique, ou / / zéro si elle ne peut être représentée sous forme d'URL cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path] ; | ||
Obtenir une structure pour revenir à JavaScript NSDictionary * entrée = [filePlugin makeEntryForLocalURL:url] | ||
@@ -119,3 +101,3 @@ | ||
var cdvfileURL = entry.toURL(); | ||
var cdvfileURL = entry.toURL() ; | ||
@@ -125,8 +107,3 @@ | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
créer l'entrée de var d'objet entrée appropriée ; | ||
Si (entryStruct.isDirectory) {entrée = new DirectoryEntry (entryStruct.name, entryStruct.fullPath, nouveau FileSystem(entryStruct.filesystemName));} else {entrée = nouvelle FileEntry (entryStruct.name, entryStruct.fullPath, nouvelle FileSystem(entryStruct.filesystemName));} |
@@ -22,61 +22,49 @@ <!--- | ||
Queste note sono principalmente destinate agli sviluppatori di Android e iOS che vogliono scrivere plugin quale interfaccia con il sistema di file utilizzando il File del plugin. | ||
Queste note sono destinate principalmente per gli sviluppatori di Android e iOS che vogliono scrivere plugin quale interfaccia con il sistema di file utilizzando il File plugin. | ||
## Lavorare con file di Cordova sistema gli URL | ||
## Lavorando con URL di sistema file di Cordova | ||
Dalla versione 1.0.0, questo plugin ha utilizzato gli URL con un `cdvfile` regime per tutte le comunicazioni oltre il ponte, piuttosto che esporre i percorsi del dispositivo raw file system a JavaScript. | ||
Dalla versione 1.0.0, questo plugin ha utilizzato gli URL con un `cdvfile` schema per tutte le comunicazioni oltre il ponte, piuttosto che esporre i percorsi del file system di dispositivo raw a JavaScript. | ||
Sul lato JavaScript, questo significa che gli oggetti FileEntry e DirectoryEntry hanno un attributo fullPath che è relativo alla directory principale del sistema di file HTML. Se JavaScript API del vostro plugin accetta un oggetto FileEntry o DirectoryEntry, dovrebbe chiamare `.toURL()` su quell'oggetto prima di passarlo attraverso il ponte in codice nativo. | ||
Sul lato JavaScript, questo significa che gli oggetti FileEntry e DirectoryEntry dispongano di un attributo fullPath che è relativo alla directory principale del sistema di file HTML. Se API JavaScript del vostro plugin accetta un oggetto FileEntry o DirectoryEntry, è necessario chiamare `.toURL()` su quell'oggetto prima di passarlo attraverso il ponte in codice nativo. | ||
### Conversione cdvfile: / / URL per percorsi fileystem | ||
### Conversione cdvfile: / / URL ai percorsi fileystem | ||
Plugin che occorre scrivere al filesystem potrebbe voler convertire un URL del sistema file ricevuto in una filesystem effettiva posizione. Ci sono diversi modi di fare questo, a seconda della piattaforma nativa. | ||
Plugin che hanno bisogno di scrivere il filesystem può essere necessario convertire un URL di sistema del file ricevuto in un percorso effettivo filesystem. Ci sono diversi modi di fare questo, a seconda della piattaforma nativa. | ||
È importante ricordare che non tutti i `cdvfile://` gli URL sono mappabili ai veri file sul dispositivo. Alcuni URL può riferirsi a beni sul dispositivo che non sono rappresentati da file, o possono anche riferirsi a risorse remote. A causa di queste possibilità, plugin dovrebbe sempre verificare se ottengono un risultato espressivo indietro quando si tenta di convertire gli URL in tracciati. | ||
È importante ricordare che non tutti i `cdvfile://` URL sono mappabili ai veri file sul dispositivo. Alcuni URL può riferirsi a beni sul dispositivo che non sono rappresentate da file, o possono anche fare riferimento a risorse remote. A causa di queste possibilità, plugin dovrebbe sempre verificare se ottengono un risultato significativo indietro quando si tenta di convertire gli URL in percorsi. | ||
#### Android | ||
Su Android, il metodo più semplice per convertire un `cdvfile://` URL a un percorso di file System è quello di utilizzare `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`dispone di diversi metodi in grado di gestire `cdvfile://` URL: | ||
Su Android, il metodo più semplice per convertire un `cdvfile://` URL a un percorso di file System è quello di utilizzare `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`dispone di diversi metodi che è possono gestire `cdvfile://` URL: | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
webView è un membro del Plugin classe CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
Ottenere un URL file:/// che rappresenta questo file sul dispositivo, / / o lo stesso URL invariata se non può essere mappato a un file Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
È anche possibile utilizzare direttamente il File del plugin: | ||
È anche possibile utilizzare direttamente il File plugin: | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
importazione org.apache.cordova.file.FileUtils; | ||
importazione org.apache.cordova.file.FileSystem; | ||
importazione java.net.MalformedURLException; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
Ottenere il File plugin dal gestore plugin FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
Dato un URL, ottenere un percorso per esso prova {String path = filePlugin.filesystemPathForURL(cdvfileURL);}} catch (MalformedURLException e) {/ / l'url del file System non è stato riconosciuto} | ||
Per convertire da un percorso a un `cdvfile://` URL: | ||
Convertire da un percorso a un `cdvfile://` URL: | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
importazione org.apache.cordova.file.LocalFilesystemURL; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
Ottenere un oggetto LocalFilesystemURL per un percorso di dispositivo, / / oppure null se non può essere rappresentata come un URL di cdvfile. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
Ottenere la rappresentazione di stringa dell'URL oggetto String cdvfileURL = url.toString(); | ||
Se il tuo plugin crea un file e si desidera restituire un oggetto FileEntry per esso, utilizzare il File del plugin: | ||
Se il vostro plugin crea un file e si desidera restituire un oggetto FileEntry per esso, utilizzare il File plugin: | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
Restituire una struttura JSON appropriato per restituire a JavaScript, / / o null se questo file non è rappresentabile come un URL di cdvfile. | ||
Voce di JSONObject = filePlugin.getEntryForFile(file); | ||
@@ -86,24 +74,18 @@ | ||
Cordova su iOS non utilizza lo stesso `CordovaResourceApi` concetto come Android. Su iOS, è necessario utilizzare il File del plugin per la conversione tra URL e percorsi del file System. | ||
Cordova su iOS non utilizza lo stesso `CordovaResourceApi` concetto come Android. Su iOS, si dovrebbe utilizzare il plugin File per convertire tra URL e percorsi di file System. | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
Ottenere un oggetto CDVFilesystem URL da una stringa CDVFilesystemURL * url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
Ottenere un percorso per l'oggetto URL, o zero se non può essere mappato a un percorso di file NSString * = [filePlugin filesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
Ottenere un oggetto CDVFilesystem URL per un percorso di dispositivo, o / / nullo se non può essere rappresentata come un URL di cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
Ottenere la rappresentazione di stringa dell'URL oggetto NSString * cdvfileURL = [absoluteString url]; | ||
Se il tuo plugin crea un file e si desidera restituire un oggetto FileEntry per esso, utilizzare il File del plugin: | ||
Se il vostro plugin crea un file e si desidera restituire un oggetto FileEntry per esso, utilizzare il File plugin: | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
Ottenere un oggetto CDVFilesystem URL per un percorso di dispositivo, o / / nullo se non può essere rappresentata come un URL di cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
Ottenere una struttura per tornare alla voce JavaScript NSDictionary * = [filePlugin makeEntryForLocalURL:url] | ||
@@ -118,10 +100,5 @@ | ||
Nei gestori di risposta plugin, per convertire da una struttura FileEntry restituita in un oggetto effettivo della voce, il codice del gestore dovrebbe importare il File del plugin e creare un nuovo oggetto: | ||
Nei gestori di risposta del plugin, per convertire da una struttura FileEntry restituita in un oggetto reale di voce, il codice del gestore dovrebbe importare il File plugin e creare un nuovo oggetto: | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
creare la voce appropriata a voce oggetto var; | ||
Se (entryStruct.isDirectory) {voce = new DirectoryEntry (entryStruct.name, entryStruct.fullPath, nuovo FileSystem(entryStruct.filesystemName));} altro {voce = FileEntry nuovo (entryStruct.name, entryStruct.fullPath, nuovo FileSystem(entryStruct.filesystemName));} |
@@ -20,63 +20,51 @@ <!--- | ||
# プラグイン開発者のためのノート | ||
# プラグイン開発者のためのメモ | ||
これらのノートは、主に人造人間と iOS 開発者向けファイルのプラグインを使用して、ファイル システムでプラグインのインターフェイスを記述するもの。 | ||
これらのノートは主に Android と iOS 開発者インタ フェース ファイルのプラグインを使用してファイル システムでプラグインを書きたい人向け。 | ||
## コルドバのファイル システムの Url の操作 | ||
## コルドバのファイル システムの Url での作業 | ||
バージョン 1.0.0 以降このプラグインが使用した Url とは `cdvfile` raw デバイス ファイル システム パスを JavaScript に公開するのではなく、ブリッジ上のすべての通信方式します。 | ||
バージョン 1.0.0 では、以来、このプラグインを含む Url を使用する `cdvfile` JavaScript に raw デバイス ファイル システムのパスを公開するのではなく、橋の上のすべての通信方式します。 | ||
JavaScript 側認証と DirectoryEntry オブジェクトの HTML ファイル システムのルートからの相対である fullPath 属性があることを意味します。 呼び出す必要がありますプラグインの JavaScript API は、認証または DirectoryEntry オブジェクトを受け入れる場合 `.toURL()` 、橋を渡ってネイティブ コードに渡す前に、そのオブジェクト。 | ||
JavaScript 側では、これはファイルと DirectoryEntry オブジェクトに HTML ファイル システムのルートを基準として、fullPath 属性があることを意味します。 あなたのプラグインの JavaScript API がファイルまたは DirectoryEntry オブジェクトを受け入れる場合を呼び出す必要があります `.toURL()` 橋を渡ってそれをネイティブ コードに渡す前にそのオブジェクトの。 | ||
### Cdvfile を変換する://fileystem のパスに Url | ||
### Cdvfile に変換する://fileystem のパスに Url | ||
ファイルシステムへの書き込みする必要があるプラグインは実際のファイルシステムの場所に受信ファイル用の URL を変換したい可能性があります。ネイティブのプラットフォームによって、これを行うための複数の方法があります。 | ||
ファイルシステムへの書き込みする必要があるプラグインは、実際のファイルシステムの場所に受信したファイル システム URL に変換する必要があります。ネイティブ プラットフォームによって、これを行うための複数の方法があります。 | ||
覚えておくことが重要ですすべてではない `cdvfile://` の Url はデバイス上の実際のファイルをマッピング可能な。 いくつかの Url は、ファイルでは表されないまたはリモートのリソースを参照することができますもをデバイス上の資産を参照できます。 プラグインはこれらの可能性のために彼らの Url パスに変換するしようとしているときに戻って、有意義な結果を得るかどうか常にテスト必要があります。 | ||
それを覚えていることが重要ですすべて `cdvfile://` の Url がデバイス上の実際のファイルをマッピング可能な。 いくつかの Url は、ファイルでは表されないまたはリモート リソースを参照することができますもデバイス上の資産を参照できます。 これらの可能性のためのプラグインは、戻るときにパスに Url を変換しようとして、彼らは意味のある結果を得るかどうか常にテスト必要があります。 | ||
#### アンドロイド | ||
Android 上で変換する最も簡単な方法は `cdvfile://` を使用してファイルシステムのパスに URL が `org.apache.cordova.CordovaResourceApi` 。 `CordovaResourceApi`扱うことができるいくつかの方法があります `cdvfile://` Url: | ||
アンドロイド, に変換する最も簡単な方法で、 `cdvfile://` を使用するファイルシステムのパスに URL は `org.apache.cordova.CordovaResourceApi` 。 `CordovaResourceApi`扱うことができるいくつかの方法は、 `cdvfile://` の Url: | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
webView プラグイン クラス CordovaResourceApi resourceApi のメンバーである = webView.getResourceApi()。 | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
デバイスでこのファイルを表す file:///URL を取得//ファイル Uri fileURL にマップできない場合、同じ URL は変更されません = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
また、ファイル プラグインを直接使用することが可能です。 | ||
また、ファイルのプラグインを直接使用することが可能です。 | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
インポート org.apache.cordova.file.FileUtils; | ||
インポート org.apache.cordova.file.FileSystem; | ||
インポート java.net.MalformedURLException; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
プラグイン マネージャーからファイルのプラグインを入手してコマンド filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
それを試みるためにパスを取得 URL を指定すると、{文字列パス = filePlugin.filesystemPathForURL(cdvfileURL);} キャッチ (MalformedURLException e) {/ファイルシステムの url が認識されませんでした/} | ||
パスから変換する、 `cdvfile://` の URL: | ||
パスから変換する、 `cdvfile://` URL: | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
インポート org.apache.cordova.file.LocalFilesystemURL; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
デバイス ・ パスの LocalFilesystemURL オブジェクトを取得//cdvfile URL として表現できない場合は null。 | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
URL オブジェクトの文字列 cdvfileURL の文字列表現を取得する = url.toString(); | ||
あなたのプラグインは、ファイルを作成し、認証オブジェクトを返す場合ファイルのプラグインを使用: | ||
あなたのプラグインは、ファイルを作成しをファイル オブジェクトを返す場合、ファイルのプラグインを使用します。 | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
JavaScript を返すときに適した JSON 構造を返す//このファイルは cdvfile URL として表現できない場合は null。 | ||
JSONObject エントリ = filePlugin.getEntryForFile(file); | ||
@@ -86,24 +74,18 @@ | ||
IOS にコルドバと同じ使用しない `CordovaResourceApi` アンドロイドとして概念。IOS、上ファイル プラグインを使用して Url をファイルシステムのパスに変換する必要があります。 | ||
IOS のコルドバは同じを使用しない `CordovaResourceApi` アンドロイドとしての概念。IOS では、Url とファイルシステムのパスの間を変換するファイル プラグインを使用する必要があります。 | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
URL の文字列 CDVFilesystemURL * url から CDVFilesystem URL オブジェクトを取得 [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
ファイル NSString * パスにマップできない場合は nil または URL オブジェクトのパスを取得 [filePlugin filesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
デバイス ・ パスの CDVFilesystem の URL オブジェクトを取得または//cdvfile URL として表現できない場合は nil です。 | ||
CDVFilesystemURL の url = [filePlugin fileSystemURLforLocalPath:path]; | ||
URL オブジェクト NSString * cdvfileURL の文字列表現を取得する = [url absoluteString]; | ||
あなたのプラグインは、ファイルを作成し、認証オブジェクトを返す場合ファイルのプラグインを使用: | ||
あなたのプラグインは、ファイルを作成しをファイル オブジェクトを返す場合、ファイルのプラグインを使用します。 | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
デバイス ・ パスの CDVFilesystem の URL オブジェクトを取得または//cdvfile URL として表現できない場合は nil です。 | ||
CDVFilesystemURL の url = [filePlugin fileSystemURLforLocalPath:path]; | ||
JavaScript NSDictionary * エントリに戻る構造を得る = [filePlugin makeEntryForLocalURL:url] | ||
@@ -113,3 +95,3 @@ | ||
Java スクリプトの設定を取得するには `cdvfile://` 認証または DirectoryEntry オブジェクトから URL を単に呼び出す `.toURL()` に: | ||
Java スクリプトの設定を取得するに、 `cdvfile://` ファイルまたは DirectoryEntry オブジェクトからの URL を呼び出して、 `.toURL()` それを。 | ||
@@ -119,10 +101,5 @@ var cdvfileURL = entry.toURL(); | ||
プラグインハンドラーの応答で返された FileEntry 構造体の実際のエントリ オブジェクトを変換するハンドラーのコードする必要がありますファイル プラグインをインポートし、新しいオブジェクトを作成します。 | ||
プラグイン応答ハンドラーに返された FileEntry 構造体の実際のエントリ オブジェクトを変換する、ハンドラーのコード ファイルのプラグインをインポート、新しいオブジェクトを作成します。 | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
適切なエントリ オブジェクト var エントリを作成します。 | ||
場合 (entryStruct.isDirectory) {エントリ = 新しい DirectoryEntry (entryStruct.name、entryStruct.fullPath、新しい FileSystem(entryStruct.filesystemName));} 他 {エントリ = 新しいファイル (entryStruct.name、entryStruct.fullPath、新しい FileSystem(entryStruct.filesystemName));} |
@@ -24,7 +24,7 @@ <!--- | ||
## 코르 도우 바 파일 시스템 Url 작업 | ||
## 코르 도우 바 파일 시스템 Url 사용 | ||
버전 1.0.0, 이후이 플러그인과 Url 사용은 `cdvfile` 교량, 모든 통신 체계 보다는 자바 원시 장치 파일 시스템 경로 노출. | ||
버전 1.0.0, 이후이 플러그인과 Url 사용 하고있다는 `cdvfile` 교량, 모든 통신에 대 한 제도 보다는 자바 원시 장치 파일 시스템 경로 노출. | ||
자바 스크립트 측면에서 즉, FileEntry 및 DirectoryEntry 개체 fullPath 속성을 HTML 파일 시스템의 루트에 상대적입니다. FileEntry 또는 DirectoryEntry 개체를 수락 하는 플러그인의 자바 API를 호출 해야 `.toURL()` 다리에 걸쳐 네이티브 코드에 전달 하기 전에 해당 개체에. | ||
자바 스크립트 측면에서 즉 그 FileEntry 및 DirectoryEntry 개체 fullPath 속성을 HTML 파일 시스템의 루트에 상대적입니다. FileEntry 또는 DirectoryEntry 개체를 수락 하는 플러그인의 자바 API를 호출 해야 `.toURL()` 다리에 걸쳐 네이티브 코드에 전달 하기 전에 해당 개체에. | ||
@@ -35,3 +35,3 @@ ### Cdvfile 변환: / / fileystem 경로 Url | ||
기억 하는 것이 중요 하다 모든 `cdvfile://` Url은 장치에 실제 파일을 매핑. 일부 Url 파일에 의해 표현 되지 않는 또는 심지어 원격 리소스를 참조할 수 있는 장치에 자산을 참조할 수 있습니다. 이러한 가능성 때문에 플러그인 경로를 Url을 변환 하려고 할 때 다시 의미 있는 결과 얻을 지 여부를 항상 테스트 해야 합니다. | ||
기억 하는 것이 중요 하다 모든 `cdvfile://` Url은 실제 파일 장치에 매핑. 일부 Url 파일에 의해 표현 되지 않는 또는 심지어 원격 리소스를 참조할 수 있는 장치에 자산을 참조할 수 있습니다. 이러한 가능성 때문에 플러그인 경로를 Url을 변환 하려고 할 때 다시 의미 있는 결과 얻을 지 여부를 항상 테스트 해야 합니다. | ||
@@ -42,8 +42,5 @@ #### 안 드 로이드 | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
webView 플러그인 클래스 CordovaResourceApi resourceApi의 멤버인 = webView.getResourceApi(); | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
장치에이 파일을 나타내는 file:/// URL 얻기 / / 같은 URL 변경 파일 Uri fileURL에 매핑할 수 없는 경우 또는 = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
@@ -53,15 +50,9 @@ | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
가져오기 org.apache.cordova.file.FileUtils; | ||
가져오기 org.apache.cordova.file.FileSystem; | ||
가져오기 java.net.MalformedURLException; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
플러그인 관리자에서 파일 플러그인을 얻을 FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
그것 시도 대 한 경로 얻을 URL을 감안할 때, {문자열 경로 = filePlugin.filesystemPathForURL(cdvfileURL);} catch (MalformedURLException e) {/ / 파일 시스템 url 인식 되지 않았습니다} | ||
@@ -71,9 +62,7 @@ | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
가져오기 org.apache.cordova.file.LocalFilesystemURL; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
장치 경로 대 한 LocalFilesystemURL 개체를 가져오기 / / cdvfile URL로 나타낼 수 없는 경우 null. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
URL 개체 문자열 cdvfileURL의 문자열 표현을 = url.toString(); | ||
@@ -83,5 +72,4 @@ | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
JSON 구조를 JavaScript에 반환을 위한 적당 한 반환 / /이 파일은 cdvfile URL로 표현 하는 경우 null. | ||
JSONObject 항목 = filePlugin.getEntryForFile(file); | ||
@@ -91,15 +79,11 @@ | ||
IOS에서 코르도바 같은 사용 하지 않는 `CordovaResourceApi` 안 드 로이드 개념. Ios, Url 및 파일 시스템 경로 사이의 변환할 파일 플러그인을 사용 해야 합니다. | ||
IOS에서 코르도바 같은 사용 하지 않는 `CordovaResourceApi` 안 드 로이드 개념. Ios, Url 및 파일 시스템 경로 사이 변환 파일 플러그인을 사용 해야 합니다. | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
URL 문자열 CDVFilesystemURL * url에서 CDVFilesystem URL 개체를 가져오기 = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
파일 NSString * 경로에 매핑할 수 없는 경우 URL 개체 또는 없음에 대 한 경로 얻을 = [filePlugin filesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
장치 경로 대 한 CDVFilesystem URL 개체를 가져오기 또는 / / 없음 cdvfile URL로 나타낼 수 없는 경우. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
URL 개체 NSString * cdvfileURL의 문자열 표현을 = [url absoluteString]; | ||
@@ -109,7 +93,5 @@ | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
장치 경로 대 한 CDVFilesystem URL 개체를 가져오기 또는 / / 없음 cdvfile URL로 나타낼 수 없는 경우. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
자바 스크립트 NSDictionary * 항목으로 돌아가려면 구조를 얻을 = [filePlugin makeEntryForLocalURL:url] | ||
@@ -119,3 +101,3 @@ | ||
자바 스크립트에서는 `cdvfile://` FileEntry 또는 DirectoryEntry 개체에서 URL를 호출 하면 `.toURL()` 그것에: | ||
자바 스크립트에는 `cdvfile://` FileEntry 또는 DirectoryEntry 개체에서 URL 호출 `.toURL()` 그것에: | ||
@@ -125,10 +107,5 @@ var cdvfileURL = entry.toURL(); | ||
플러그인 응답 처리기에서 반환 된 FileEntry 구조에서 실제 항목 개체 변환 하려면 처리기 코드 해야 파일 플러그인 가져오고 새 개체를 만들: | ||
플러그인 응답 처리기에서 실제 항목 개체로 반환 된 FileEntry 구조에서 변환 처리기 코드 해야 파일 플러그인 가져오고 새 개체를 만들: | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
적절 한 항목 개체 var 항목; | ||
경우 (entryStruct.isDirectory) {항목 = 새 DirectoryEntry (entryStruct.name, entryStruct.fullPath, 새로운 FileSystem(entryStruct.filesystemName));} 다른 {항목 = 새로운 FileEntry (entryStruct.name, entryStruct.fullPath, 새로운 FileSystem(entryStruct.filesystemName));} |
@@ -22,26 +22,23 @@ <!--- | ||
Te notatki są przeznaczone przede wszystkim dla Androida i iOS programistów, którzy chcieli pisac pluginy które interfejs z systemu plików za pomocą wtyczki pliku. | ||
Te notatki są przeznaczone przede wszystkim dla Androida i iOS deweloperów, którzy chcieli pisac pluginy które interfejs z systemu plików za pomocą wtyczki pliku. | ||
## Praca z Cordova pliku system adresów URL | ||
Od wersji 1.0.0, ten plugin jest używane adresy URL z `cdvfile` system do komunikacji przez most, a nie narażać urządzenia raw ścieżki systemu plików JavaScript. | ||
Od wersji 1.0.0, ten plugin ma używane adresy URL z `cdvfile` system dla wszystkich komunikacji przez most, a nie narażać urządzenia raw ścieżki systemu plików JavaScript. | ||
Na stronie JavaScript oznacza to, że FileEntry i DirectoryEntry obiekty mają fullPath atrybut, który jest głównym systemie plików HTML. Jeśli twój plugin JavaScript API akceptuje obiektu DirectoryEntry lub FileEntry, należy zadzwonić `.toURL()` na obiekt przed przekazaniem przez most do kodu macierzystego. | ||
Na stronie JavaScript oznacza to, że FileEntry i DirectoryEntry obiekty mają fullPath atrybut, który jest głównym systemie plików HTML. Jeśli twój plugin JavaScript API akceptuje obiektu FileEntry lub DirectoryEntry, należy zadzwonić `.toURL()` dla tego obiektu przed przekazaniem Altpradl do kodu macierzystego. | ||
### Konwersja cdvfile: / / URL do ścieżki fileystem | ||
Wtyczek, które trzeba pisać do systemu plików może chcesz przekonwertować odebranych plików systemu adres URL lokalizacji rzeczywistych plików. Istnieje wiele sposobów działania, od macierzystego platformy. | ||
Wtyczek, które trzeba pisać do systemu plików może chcesz przekonwertować odebranych plików systemu adres URL lokalizacji rzeczywistych plików. Istnieje wiele sposobów robi to, w zależności od macierzystego platformy. | ||
Ważne jest, aby pamiętać, że nie wszystkie `cdvfile://` adresy URL są można zmapować na prawdziwe akta urządzeniu. Niektóre adresy URL może odnosić się do aktywów na urządzeniu, które nie są reprezentowane przez pliki, lub nawet może odnosić się do zasobów zdalnych. Z powodu tych możliwości wtyczki należy zawsze sprawdzić, czy się znaczących wyników wstecz, podczas próby konwersji adresów URL do ścieżki. | ||
Ważne jest, aby pamiętać, że nie wszystkie `cdvfile://` adresy URL są można zmapować na prawdziwe pliki w urządzeniu. Niektóre adresy URL może odnosić się do aktywów na urządzeniu, które nie są reprezentowane przez pliki, lub nawet może odnosić się do zasobów zdalnych. Ze względu na te możliwości wtyczki należy zawsze sprawdzić, czy się znaczącego wyniku powrót podczas próby konwersji adresów URL do ścieżki. | ||
#### Android | ||
#### Androida | ||
Na Android, najprostsza metoda konwersji `cdvfile://` URL do ścieżki systemu plików jest użycie `org.apache.cordova.CordovaResourceApi` . `CordovaResourceApi`jest kilka metod, które mogą obsługiwać `cdvfile://` adresów URL: | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
Widok sieci Web jest członkiem Plugin klasy CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
Uzyskać URL file:/// reprezentujących ten plik na urządzeniu / / lub ten sam adres URL niezmienione, jeśli nie mogą być mapowane do pliku fileURL Uri = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
@@ -51,26 +48,18 @@ | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
org.apache.cordova.file.FileUtils przywóz; | ||
org.apache.cordova.file.FileSystem przywóz; | ||
java.net.MalformedURLException przywóz; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
Uzyskać pliku plugin manager wtyczki FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
Biorąc pod uwagę adres URL, uzyskać ścieżkę dla to spróbuj {String ścieżka = filePlugin.filesystemPathForURL(cdvfileURL);} catch (MalformedURLException e) {/ / url plików nie było uznane} | ||
Do przeliczenia ścieżki do `cdvfile://` adres URL: | ||
Do przeliczenia ścieżki do `cdvfile://` URL: | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
org.apache.cordova.file.LocalFilesystemURL przywóz; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
Uzyskanie obiektu LocalFilesystemURL na ścieżkę urządzenia / / lub null, jeśli nie może być reprezentowana jako adres URL cdvfile. | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
Dostać reprezentację ciąg adresu URL obiektu String cdvfileURL = url.toString(); | ||
@@ -80,5 +69,4 @@ | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
Zwraca JSON struktura nadaje się do powrotu do JavaScript, / / lub null, jeśli ten plik nie jest reprezentować jako adres URL cdvfile. | ||
Wpis JSONObject = filePlugin.getEntryForFile(file); | ||
@@ -90,13 +78,9 @@ | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
Uzyskać obiekt CDVFilesystem URL URL url ciąg CDVFilesystemURL * = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
Uzyskać ścieżkę dla URL obiektu, stawka zerowa, jeśli nie mogą być mapowane do ścieżki pliku NSString * = [filePlugin filesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
Dostać CDVFilesystem URL obiektu na ścieżkę urządzenia lub / / zerowe, jeśli nie może być reprezentowana jako adres URL cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
Dostać reprezentację ciąg adresu URL obiektu NSString * cdvfileURL = [url absoluteString]; | ||
@@ -106,7 +90,5 @@ | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
Dostać CDVFilesystem URL obiektu na ścieżkę urządzenia lub / / zerowe, jeśli nie może być reprezentowana jako adres URL cdvfile. | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
Struktura wrócić do JavaScript NSDictionary * wpis = [filePlugin makeEntryForLocalURL:url] | ||
@@ -121,10 +103,5 @@ | ||
W plugin obsługi odpowiedzi do przeliczenia strukturę FileEntry wrócił do rzeczywistego obiektu wejścia, kod obsługi należy importować pliku plugin i utworzyć nowy obiekt: | ||
W plugin reakcji obsługi przerobić od zwróconych struktury FileEntry do rzeczywistego obiektu wejścia, kod obsługi należy zaimportować pliku plugin i utworzyć nowy obiekt: | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
utworzyć odpowiedni wpis obiektu var wpis; | ||
Jeśli (entryStruct.isDirectory) {wpis = nowy DirectoryEntry (entryStruct.name, entryStruct.fullPath, nowe FileSystem(entryStruct.filesystemName));} jeszcze {wpis = nowy FileEntry (entryStruct.name, entryStruct.fullPath, nowe FileSystem(entryStruct.filesystemName));} |
@@ -20,63 +20,51 @@ <!--- | ||
# 外掛程式開發人員須知 | ||
# 外掛程式開發人員注意事項 | ||
這些筆記主要針對 Android 和 iOS 開發者想要使用的檔案系統使用的檔外掛程式編寫外掛程式哪個介面。 | ||
這些筆記主要用於 Android 和 iOS 開發者想要編寫外掛程式的介面與使用檔外掛程式的檔案系統。 | ||
## 工作與科爾多瓦檔案系統 Url | ||
1.0.0 版以來,這個外掛程式用了 Url 與 `cdvfile` 在橋樑,為所有的通信計畫,而不是暴露 JavaScript 原始設備的檔案系統路徑。 | ||
自從版本 1.0.0,這個外掛程式一直使用 Url 與 `cdvfile` 大橋,計畫為所有通信,而不是揭露 JavaScript 的原始設備檔案系統路徑。 | ||
在 JavaScript 方面,這意味著 FileEntry 和 DirectoryEntry 的物件具有一個完整路徑屬性是相對於 HTML 檔案系統的根目錄。 如果你的外掛程式的 JavaScript API 接受 FileEntry 或 DirectoryEntry 的物件,則應調用 `.toURL()` 對該物件之前將它在橋上傳遞給本機代碼。 | ||
在 JavaScript 方面,這意味著 FileEntry 和 DirectoryEntry 的物件有一個完整路徑屬性是相對於 HTML 檔案系統的根目錄。 如果你的外掛程式的 JavaScript API 接受一個 FileEntry 或 DirectoryEntry 的物件,你應該打電話給 `.toURL()` 對該物件之前將它從橋上傳遞給本機代碼。 | ||
### 轉換 cdvfile: / / fileystem 的路徑的 Url | ||
### 轉換 cdvfile: / / fileystem 路徑的 Url | ||
需要寫入到檔案系統的外掛程式可能會想要將收到的檔案系統的 URL 轉換為實際的檔案系統位置。有多種方法做這個,根據本機平臺。 | ||
需要寫入到檔案系統的外掛程式可能想要將接收的檔案系統 URL 轉換為實際的檔案系統位置。有做這,根據本機平臺的多種方式。 | ||
它是重要的是要記住,不是所有 `cdvfile://` 的 Url 均可映射到設備上的實際檔。 某些 Url 可以引用在設備上不是由檔,或甚至可以引用遠端資源的資產。 由於這些可能性,外掛程式應始終測試是否回試圖將 Url 轉換成路徑時,他們得到有意義的結果。 | ||
很重要的是要記住,並不是所有 `cdvfile://` Url 是可映射到設備上的實際檔。 某些 Url 可以指在設備上沒有代表的檔,或甚至可以引用遠端資源的資產。 由於這些可能性,外掛程式應始終測試是否回來時試圖將 Url 轉換成路徑得到有意義的結果。 | ||
#### Android 系統 | ||
#### 安卓系統 | ||
在 android 系統,最簡單的方法來轉換 `cdvfile://` 檔案系統路徑的 URL 是使用 `org.apache.cordova.CordovaResourceApi` 。 `CordovaResourceApi`有幾種方法,可處理 `cdvfile://` 的 Url: | ||
在 android 系統,最簡單的方法來轉換 `cdvfile://` 檔案系統路徑的 URL 是使用 `org.apache.cordova.CordovaResourceApi` 。 `CordovaResourceApi`有幾種方法,可處理 `cdvfile://` 網址: | ||
// webView is a member of the Plugin class | ||
CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
web 視圖是成員的外掛程式類 CordovaResourceApi resourceApi = webView.getResourceApi(); | ||
// Obtain a file:/// URL representing this file on the device, | ||
// or the same URL unchanged if it cannot be mapped to a file | ||
Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
獲取表示此檔在設備上,file:/// URL / / 或 URL 相同變的如果它不能映射到檔 Uri fileURL = resourceApi.remapUri(Uri.parse(cdvfileURL)); | ||
它也是可以直接使用檔外掛程式: | ||
它也是可以直接使用檔外掛程式: | ||
import org.apache.cordova.file.FileUtils; | ||
import org.apache.cordova.file.FileSystem; | ||
import java.net.MalformedURLException; | ||
導入 org.apache.cordova.file.FileUtils; | ||
導入 org.apache.cordova.file.FileSystem; | ||
導入 java.net.MalformedURLException; | ||
// Get the File plugin from the plugin manager | ||
FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
得到檔外掛程式外掛程式管理器從 FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); | ||
// Given a URL, get a path for it | ||
try { | ||
String path = filePlugin.filesystemPathForURL(cdvfileURL); | ||
} catch (MalformedURLException e) { | ||
// The filesystem url wasn't recognized | ||
} | ||
給定 URL,得到的路徑,因為它嘗試 {字串路徑 = filePlugin.filesystemPathForURL(cdvfileURL);} 趕上 (MalformedURLException e) {/ / 檔案系統 url 不承認} | ||
要轉換的路徑從 `cdvfile://` 的 URL: | ||
要轉換到的路徑從 `cdvfile://` URL: | ||
import org.apache.cordova.file.LocalFilesystemURL; | ||
導入 org.apache.cordova.file.LocalFilesystemURL; | ||
// Get a LocalFilesystemURL object for a device path, | ||
// or null if it cannot be represented as a cdvfile URL. | ||
獲取設備的路徑,一個 LocalFilesystemURL 物件 / / 或如果它不能表示為 cdvfile 的 URL,則為 null。 | ||
LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(path); | ||
// Get the string representation of the URL object | ||
String cdvfileURL = url.toString(); | ||
得到的字串表示形式的 URL 物件字串 cdvfileURL = url.toString(); | ||
如果你的外掛程式創建一個檔,並且您想要為它返回一個 FileEntry 物件,使用該檔外掛程式: | ||
如果你的外掛程式創建一個檔,並且您想要為它返回一個 FileEntry 物件,使用該檔的外掛程式: | ||
// Return a JSON structure suitable for returning to JavaScript, | ||
// or null if this file is not representable as a cdvfile URL. | ||
JSONObject entry = filePlugin.getEntryForFile(file); | ||
返回一個 JSON 結構適合於回到 JavaScript,/ / 或如果此檔不是可表示為 cdvfile 的 URL,則為 null。 | ||
JSONObject 條目 = filePlugin.getEntryForFile(file); | ||
@@ -86,24 +74,18 @@ | ||
科爾多瓦在 iOS 上的不使用相同 `CordovaResourceApi` 作為 android 系統的概念。在 iOS,應使用檔外掛程式的 Url 和檔案系統路徑之間進行轉換。 | ||
科爾多瓦在 iOS 上的不使用相同 `CordovaResourceApi` 作為 android 系統的概念。在 iOS,應使用檔外掛程式 Url 和檔案系統路徑之間進行轉換。 | ||
// Get a CDVFilesystem URL object from a URL string | ||
CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
// Get a path for the URL object, or nil if it cannot be mapped to a file | ||
NSString* path = [filePlugin filesystemPathForURL:url]; | ||
獲取一個物件,CDVFilesystem URL 從 url 字串 CDVFilesystemURL * = [CDVFilesystemURL fileSystemURLWithString:cdvfileURL]; | ||
獲取路徑 URL 物件,或為零,如果它不能映射到檔 NSString * 路徑 = [filePlugin filesystemPathForURL:url]; | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get the string representation of the URL object | ||
NSString* cdvfileURL = [url absoluteString]; | ||
CDVFilesystem URL 物件獲取設備的路徑,或 / / 為零,如果它不能表示為 cdvfile 的 URL。 | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
得到的字串表示形式的 URL 物件 NSString * cdvfileURL = [url absoluteString]; | ||
如果你的外掛程式創建一個檔,並且您想要為它返回一個 FileEntry 物件,使用該檔外掛程式: | ||
如果你的外掛程式創建一個檔,並且您想要為它返回一個 FileEntry 物件,使用該檔的外掛程式: | ||
// Get a CDVFilesystem URL object for a device path, or | ||
// nil if it cannot be represented as a cdvfile URL. | ||
CDVFilesystemURL* url = [filePlugin fileSystemURLforLocalPath:path]; | ||
// Get a structure to return to JavaScript | ||
NSDictionary* entry = [filePlugin makeEntryForLocalURL:url] | ||
CDVFilesystem URL 物件獲取設備的路徑,或 / / 為零,如果它不能表示為 cdvfile 的 URL。 | ||
CDVFilesystemURL * url = [filePlugin fileSystemURLforLocalPath:path]; | ||
得到一個結構來返回進入 JavaScript NSDictionary * = [filePlugin makeEntryForLocalURL:url] | ||
@@ -113,3 +95,3 @@ | ||
在 JavaScript 中,得到 `cdvfile://` URL 從 FileEntry 或 DirectoryEntry 的物件,只需調用 `.toURL()` 對它: | ||
在 JavaScript 中,得到 `cdvfile://` URL 從 FileEntry 或 DirectoryEntry 的物件,只需調用 `.toURL()` 對它: | ||
@@ -119,10 +101,5 @@ var cdvfileURL = entry.toURL(); | ||
在外掛程式回應處理常式,將從返回的 FileEntry 結構轉換為實際的輸入物件,您的處理常式代碼應該導入的檔外掛程式並創建一個新的物件: | ||
在外掛程式回應處理常式,將從返回的 FileEntry 結構轉換為實際的條目物件,處理常式代碼應該導入檔外掛程式和創建新的物件: | ||
// create appropriate Entry object | ||
var entry; | ||
if (entryStruct.isDirectory) { | ||
entry = new DirectoryEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} else { | ||
entry = new FileEntry(entryStruct.name, entryStruct.fullPath, new FileSystem(entryStruct.filesystemName)); | ||
} | ||
創建適當的條目物件 var 條目; | ||
如果 (entryStruct.isDirectory) {條目 = 新目錄 (entryStruct.name,entryStruct.fullPath,新 FileSystem(entryStruct.filesystemName));} 其他 {條目 = 新的 FileEntry (entryStruct.name,entryStruct.fullPath,新 FileSystem(entryStruct.filesystemName));} |
{ | ||
"name": "cordova-plugin-file", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Cordova File Plugin", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -22,4 +22,2 @@ <!-- | ||
[](https://travis-ci.org/apache/cordova-plugin-file) | ||
This plugin implements a File API allowing read/write access to files residing on the device. | ||
@@ -220,3 +218,3 @@ | ||
Without this line, the File plugin will use `Compatibility` as the default. If | ||
Without this line, the File plugin will use `Internal` as the default. If | ||
a preference tag is present, and is not one of these values, the application | ||
@@ -226,4 +224,4 @@ will not start. | ||
If your application has previously been shipped to users, using an older (pre- | ||
1.0) version of this plugin, and has stored files in the persistent filesystem, | ||
then you should set the preference to `Compatibility`. Switching the location to | ||
3.0.0) version of this plugin, and has stored files in the persistent filesystem, | ||
then you should set the preference to `Compatibility` if your config.xml does not specify a location for the persistent filesystem. Switching the location to | ||
"Internal" would mean that existing users who upgrade their application may be | ||
@@ -230,0 +228,0 @@ unable to access their previously-stored files, depending on their device. |
@@ -365,1 +365,7 @@ <!-- | ||
* CB-8792 Fixes reading of json files using readAsText | ||
### 3.0.0 (Aug 18, 2015) | ||
* Make Android default persistent file location internal | ||
* Fixed issue with file paths not existing when using browserify | ||
* CB-9251: Changed from Intents to Preferences object as per the issue | ||
* CB-9215 Add cordova-plugin-file manual test for windows platform |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1419326
118
12437
451