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
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Loads in the background the content of a resource (image, text, etc.) identified by its URI in a buffer variable.
Example
AndroidAndroid Widget
// Open the system window to select an image
UriResource is URI = URISelect(uriImage)
IF NOT ErrorOccurred THEN
// Load the resource
URIToBuffer(UriResource, ProcLoad)
INTERNAL PROCÉDURE ProcLoad(bResult, buffer)
IF bResult THEN
// Save the image in the database
HLinkMemo(Client, Photo, buffer)
HModify(Customer)
END
END
END
AndroidAndroid Widget
// 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 PROCÉDURE ProcEndLoadResources(bResult, buffer, sFormat)
IF bResult THEN
ToastDisplay("Loading completed")
END
END
END
END
Syntax
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: URISelect selects a resource and gets its URI.
  • a character string.
<WLanguage procedure>: Procedure name
Name of WLanguage procedure ("callback") called once the buffer has been loaded. This procedure has the following format:
PROCEDURE <Procedure name>(<Result>, <Buffer>, <Format)
where:
  • <Result> is a boolean:
    • True if the buffer was loaded,
    • False otherwise. To get the details of 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 corresponds to 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 will be passed as a parameter of the procedure called once the loading is completed.
Remarks

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".
Component: wd290android.aar
Versión mínima requerida
  • Versión 24
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 26/05/2022

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