Home | Sign in | English UK
New WINDEV Mobile 24 feature!
  • Management of the MIME type
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Stored procedures
URIToBuffer (Function)
In french: URIVersBuffer
Loads in the background the content of a resource (image, text, etc.) identified by its URI in a buffer variable.
// 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)
// 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))

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
// Load the resource in a buffer
URIToBuffer(UriResource, ProcEndLoadResources, sMIMEType)
INTERNAL PROCEDURE ProcEndLoadResources(bResult, buffer, sFormat)
IF bResult THEN
ToastDisplay("Loading completed")
URIToBuffer(<URI> , <Procedure> [, <MIME type>])
<URI>: URI or character string variable
Resource to load. This resource can correspond to:
  • the name of a URI variable.
    Reminder: URISelect makes it possible to select a resource and retrieve its URI.
  • a character string.
<Procedure>: Name of WLanguage procedure
Name of WLanguage procedure ("callback") called once the buffer has been loaded. This procedure has the following format:
PROCEDURE <Procedure name>(<Result>, <Buffer>, <Format)
  • <Result> is a boolean:
    • True if the buffer was loaded,
    • False otherwise. To retrieve the error details, use ErrorInfo before any other call to a WLanguage function (which 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.

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 : wd240android.jar
Minimum version required
  • Version 24
Click [Add] to post a comment