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
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
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
// Open the system window to select a pdf
UriResource is URI = URISelect("application/pdf")
IF NOT ErrorOccurred THEN
	// Save the resource in the application directory
	URIToFile(UriResource, "document.pdf", ProcSave)
	INTERNAL PROCEDURE ProcSave (bResult, sPath)
		IF bResult THEN
			ToastDisplay("Saved successfully")
		ELSE	 
			ToastDisplay("Unable to save")
		END
	END
END
AndroidWidget Android
// Save a resource with conversion 
UriResource is URI = URISelect()
IF NOT ErrorOccurred THEN
	// Retrieves the MIME type into which the resource can be converted
	sMIMEType is string = URIGetInfo (UriResource, uriInfoConversionType)
	IF sMIMEType <> "" THEN
		// If there are several possible MIME types
		IF StringCount(sMIMEType, CR) > 1 THEN
			// Ask the user to choose the type to use
			...
		END
		// Save the resource on the device
		URIToFile(UriResource, SysDirExternalStorage(1, sseAppDocument), ...
					ProcEndSave, sMIMEType)
		INTERNAL PROCEDURE ProcEndSave (bResult, sResourcePath)
			IF bResult THEN
				ToastDisplay(StringBuild("File saved (%1)", ...
						sResourcePath))
			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:
  • Or to a directory path (this directory must exist): the resource will be recorded 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.
    Warning The file extension will not be modified, even if the resource had to be converted to another format for recording.
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 <Procedure name> (<Result>, <Path>)
where:
  • <Résultat> is a 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 is 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/03/2025

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