[libgdata] demos: Port to the 0.8 version of the PicasaWeb upload API
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] demos: Port to the 0.8 version of the PicasaWeb upload API
- Date: Sun, 31 Jul 2011 00:10:35 +0000 (UTC)
commit 6cbd799733b10ad7b09f14d210c73e120e5bb244
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Jan 16 16:57:38 2011 +0000
demos: Port to the 0.8 version of the PicasaWeb upload API
demos/scrapbook/scrapbook.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/demos/scrapbook/scrapbook.c b/demos/scrapbook/scrapbook.c
index 330ab5f..68b6927 100644
--- a/demos/scrapbook/scrapbook.c
+++ b/demos/scrapbook/scrapbook.c
@@ -488,17 +488,40 @@ select_file (GtkWidget *widget, ScrapPUpload *self)
{
GFile *file;
GError *error = NULL;
+ GFileInfo *file_info;
+ GDataUploadStream *upload_stream;
+ GFileInputStream *file_stream;
+
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (self->file_dialog));
+
+ file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE, NULL, NULL);
+
/* upload our file, using the service we've set up, and metadata
* set up in upload ()
* no album is specified, but that should be easy to add */
- self->file=gdata_picasaweb_service_upload_file (self->main_data->p_search->service,
- NULL, /* for now uploading to drop box */
- self->file, file, NULL, &error);
+ upload_stream = gdata_picasaweb_service_upload_file (self->main_data->p_search->service, NULL /* for now uploading to drop box */,
+ self->file, g_file_info_get_display_name (file_info),
+ g_file_info_get_content_type (file_info), NULL, &error);
+
+ g_object_unref (file_info);
+ g_object_unref (self->file);
+
if (error != NULL) {
g_print ("error: %s\n", error->message);
}
g_free (error);
+
+ file_stream = g_file_read (file, NULL, NULL);
+ g_object_unref (file);
+
+ g_output_stream_splice (G_OUTPUT_STREAM (upload_stream), G_INPUT_STREAM (file_stream),
+ G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, NULL, NULL);
+
+ self->file = gdata_picasaweb_service_finish_file_upload (self->main_data->p_search->service, upload_stream, NULL);
+
+ g_object_unref (file_stream);
+ g_object_unref (upload_stream);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]