AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones específicas para móviles / Funciones URI
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Otros
Procedimientos almacenados
Saves, in the background, the content of a resource (image, text, etc.) identified by its URI in an external file.
Ejemplo
AndroidWidget Android
// Ouvre la fenêtre système pour la sélection d'un pdf
UriRessource is URI = URISélecteur("application/pdf")
IF NOT ErrorOccurred THEN
	// Enregistre la ressource dans le répertoire de l'application
	URIToFile(UriRessource, "document.pdf", ProcEnregistre)
	INTERNAL PROCEDURE ProcEnregistre(bResultat, sChemin)
		IF bResultat THEN
			ToastDisplay("Enregistrement terminé")
		ELSE	 
			ToastDisplay("Echec de l'enregistrement")
		END
	END
END
AndroidWidget Android
// Sauvegarde d'une ressource avec conversion 
UriRessource is URI = URISélecteur()
IF NOT ErrorOccurred THEN
	// Récupère le type MIME dans lequel la ressource peut être convertie
	sTypeMIME is string = URIRécupèreInfo(UriRessource, uriInfoConversionType)
	IF sTypeMIME <> "" THEN
		// S'il y a plusieurs types MIME possibles
		IF StringCount(sTypeMIME, CR) > 1 THEN
			// Demander à l'utilisateur de choisir le type à utiliser
			...
		END
		// Enregistre la ressource sur l'appareil
		URIToFile(UriRessource, SysDirExternalStorage(1, sseAppDocument), ...
					ProcFinEnregistre, sTypeMIME)
		INTERNAL PROCEDURE ProcFinEnregistre(bResultat, sCheminRessource)
			IF bResultat THEN
				ToastDisplay(StringBuild("Fichier enregistré (%1)", ...
						sCheminRessource))
			END
		END
	END
END
Sintaxis
URIToFile(<URI> , <Path> , <Procedure> [, <MIME type>])
<URI>: URI or character string variable
URI or character string variable that identifies the resource to save.
<Path>: Character string
Corresponds to:
  • a directory path (this directory must exist): the resource will be saved in this directory. The name of the created file will correspond to the original name of the resource, and its extension will depend on the format used to save it (see notes).
  • A full or relative file path. If the file already exists, it will be overwritten.
    Caution: the file extension will not be modified even if the resource had to be converted to another format to be saved.
The full path of the saved file will be passed as a parameter of the procedure called once the save has been completed.
<Procedure>: Name of the WLanguage procedure
Name of the WLanguage procedure ("callback") called once the save has been completed. This procedure has the following format:
PROCEDURE <Nom de la procédure>(<Résultat>, <Chemin>)
where:
  • <Result> is boolean:
    • True if the save has been completed,
    • False otherwise. To get more details on the error, use ErrorInfo before any other call to a WLanguage function (this would reinitialize the error).
  • <Path> is a character string that corresponds to the full file path used for saving.
<MIME type>: Optional character string
MIME type corresponding to the format in which the resource must be saved (see Notes).
If this parameter is not specified or corresponds to an empty string (""), the resource will be saved in its original format if possible or it will first be converted to a default format.
Observaciones
  • To select a resource and get its URI, use URISelect.
  • When the resource to save does not come from the device's file system, the content provider that manages the resource may need to convert this resource. This is usually the case if no application on the device can manage the original format of the resource. It is possible to specify the conversion format of the resource by entering the parameter <MIME type>. To find out the MIME type into which a resource can be converted, use URIGetInfo with the constant uriInfoConversionType. If this function returns an empty string (""), the resource cannot be saved. In this case, do not call URIToFile on this resource, since it will fail.
    Example:
    a Microsoft Word file (.doc or.docx) is selected using URISelect. This file is on Google Drive and no application on the device can handle this type of document. When saving this resource, the content provider will automatically convert this resource to PDF format. In this case, URIGetInfo used with the constant uriInfoConversionType will return the following string: "application/pdf + TAB + .pdf".
Componente: wd300android.aar
Versión mínima requerida
  • Versión 24
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/06/2024

Señalar un error o enviar una sugerencia | Ayuda local