gchar *rename_to = NULL;
gchar *uploadfile_as = NULL;
gchar *last_slash = NULL;
- gchar *dir_name = NULL;
gchar *tmpfile_name = NULL;
if (sink->headerlist != NULL) {
last_slash = strrchr (basesink->file_name, '/');
if (last_slash != NULL) {
- dir_name =
+ gchar *dir_name =
g_strndup (basesink->file_name, last_slash - basesink->file_name);
rename_to = g_strdup_printf ("%s%s", RENAME_TO, last_slash + 1);
uploadfile_as = g_strdup_printf ("%s/%s", dir_name, tmpfile_name);
+ g_free (dir_name);
} else {
rename_to = g_strdup_printf ("%s%s", RENAME_TO, basesink->file_name);
uploadfile_as = g_strdup_printf ("%s", tmpfile_name);
}
+ g_free (tmpfile_name);
tmp = g_strdup_printf ("%s%s", basesink->url, uploadfile_as);
+ g_free (uploadfile_as);
+
+ sink->headerlist = curl_slist_append (sink->headerlist, rename_from);
+ sink->headerlist = curl_slist_append (sink->headerlist, rename_to);
+ g_free (rename_from);
+ g_free (rename_to);
res = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+ g_free (tmp);
if (res != CURLE_OK) {
- g_free (tmp);
basesink->error = g_strdup_printf ("failed to set URL: %s",
curl_easy_strerror (res));
return FALSE;
}
- sink->headerlist = curl_slist_append (sink->headerlist, rename_from);
- sink->headerlist = curl_slist_append (sink->headerlist, rename_to);
-
res = curl_easy_setopt (basesink->curl, CURLOPT_POSTQUOTE, sink->headerlist);
if (res != CURLE_OK) {
- g_free (tmp);
basesink->error = g_strdup_printf ("failed to set post quote: %s",
curl_easy_strerror (res));
return FALSE;
}
- g_free (rename_from);
- g_free (rename_to);
- g_free (uploadfile_as);
- g_free (dir_name);
- g_free (tmpfile_name);
if (last_slash != NULL) {
*last_slash = '\0';
}
} else {
tmp = g_strdup_printf ("%s%s", basesink->url, basesink->file_name);
res = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+ g_free (tmp);
if (res != CURLE_OK) {
- g_free (tmp);
basesink->error = g_strdup_printf ("failed to set URL: %s",
curl_easy_strerror (res));
return FALSE;
}
}
- g_free (tmp);
-
return TRUE;
}
gchar *tmp = g_strdup_printf ("%s%s", basesink->url, basesink->file_name);
CURLcode curl_err = CURLE_OK;
- if ((curl_err =
- curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp)) != CURLE_OK) {
+ curl_err = curl_easy_setopt (basesink->curl, CURLOPT_URL, tmp);
+ g_free (tmp);
+ if (curl_err != CURLE_OK) {
basesink->error = g_strdup_printf ("failed to set URL: %s",
curl_easy_strerror (curl_err));
return FALSE;
}
- g_free (tmp);
-
return TRUE;
}