Function

RestParamnew_with_owner

Declaration [src]

RestParam*
rest_param_new_with_owner (
  const char* name,
  gconstpointer data,
  gsize length,
  const char* content_type,
  const char* filename,
  gpointer owner,
  GDestroyNotify owner_dnotify
)

Description [src]

Create a new RestParam called name with length bytes of data as the value. content_type is the type of the data as a MIME type, for example “text/plain” for simple string parameters.

If the parameter is a file upload it can be passed as filename.

When the RestParam is freed, it will call owner_dnotify, passing owner to it. This allows you to do something like this:

GMappedFile *map = g_mapped_file_new (filename, FALSE, &error);
RestParam *param = rest_param_new_with_owner ("media",
                                              g_mapped_file_get_contents (map),
                                              g_mapped_file_get_length (map),
                                              "image/jpeg",
                                              filename,
                                              map,
                                              (GDestroyNotify)g_mapped_file_unref);

Parameters

name const char*
 

The parameter name.

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
data An array of guint8
 

A pointer to the start of the data.

 The length of the array is specified in the length argument.
length gsize
 

The length of the data.

content_type const char*
 

The content type of the data.

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
filename const char*
 

The original filename, or NULL.

 The argument can be NULL.
 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
owner gpointer
 

Pointer to an object that owns data.

owner_dnotify GDestroyNotify
 

A function to free/unref owner when the buffer is freed.

Return value

Returns: RestParam
 

A new RestParam.

 The caller of the function takes ownership of the data, and is responsible for freeing it.