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
  • Management of the MIME type
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
Loads in the background the content of a resource (image, text, etc.) identified by its URI in a buffer variable.
Ejemplo
AndroidWidget Android
// Open the system window to select an image 
UriResource is URI = URISelect(uriImage)
IF NOT ErrorOccurred THEN
	// Load the resource
	URIToBuffer(UriResource, ProcLoad)
	INTERNAL PROCEDURE ProcLoad(bResult, buffer)
		IF bResult THEN
			// Save the image in the database
			HLinkMemo(Client, Photo, buffer)
			HModify(Customer)
		END
	END
END
AndroidWidget Android
// Load a resource with conversion 

// Open the system window to select a resource
UriResource is URI = URISelect()
IF NOT ErrorOccurred THEN
	// Displays the name of the selected resource
	Info(URIGetInfo(UriResource, uriInfoName))
END

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, TAB) > 1 THEN
			// Ask the user to choose the type to use
			...
		END
		// Load the resource in a buffer
		URIToBuffer(UriResource, ProcEndLoadResources, sMIMEType)
		INTERNAL PROCEDURE ProcEndLoadResources(bResult, buffer, sFormat)
			IF bResult THEN
				ToastDisplay("Loading completed")
			END
		END
	END
END
Sintaxis
URIToBuffer(<URI> , <WLanguage procedure> [, <MIME type>])
<URI>: URI or character string variable
Resource to load. This resource can correspond to:
  • the name of a variable of type URI.
    Reminder: the URISelect function is used to select a resource and obtain its URI.
  • a character string.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called once the buffer has been loaded. This procedure has the following format:
PROCEDURE <Procedure name>(<Result>, <Buffer>, <Format)
where:
  • <Résultat> is a Boolean:
    • True if the buffer was loaded,
    • False otherwise. To get more details on the error, use ErrorInfo before any other call to a WLanguage function (this would reinitialize the error).
  • <Buffer> is a Buffer variable initialized with the content of the resource.
  • <Format> is a character string that represents the MIME type and the file extension of the format in which the resource was loaded (it may be different from the original format if the resource was converted). This string has the following format:
    <MIME type> + TAB + <Extension>
    Example: "application/pdf + TAB + .pdf"
<MIME type>: Optional character string
MIME type corresponding to the format in which the resource must be loaded (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 into a default format.
Reminder: The format used to load the resource is passed as a parameter to the Procedure called at the end of loading.
Observaciones

Management of the MIME type

When the resource to load does not come from the device's file system, the content provider that manages the resource may need to convert it.
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 URIToBuffer 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