TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
RJ Gowtham
NA
5
4.3k
i tried to upload picture in picasa web api in c#
Dec 27 2014 4:31 AM
i tried to upload images in the picasa using picasa web api in C#, while i am tried to create new album folder it excute a exception"cannot use read only feed".please provide any solution to create an private album and upload images in picasa. please find the code below.
////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
//using System.Drawing;
using System.IO;
/////////Google data ///////////////////////
using Google.GData.Photos;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.GData.Extensions.Location;
using Google.GData.AccessControl;
namespace Picasa_upload
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
PicasaService service = new PicasaService("Testing-quliatas-1");///intial service
public MainWindow()
{
InitializeComponent();
}
/// <summary>
/// uploading image
/// </summary>
/// <param name="name"></param>
public void uploading_image(string name)
{
try
{
AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(name));
PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
string album_id = null;
string album_name = null;
foreach (PicasaEntry p in myPicasaFeed.Entries)
{
AlbumAccessor myAlbum = new AlbumAccessor(p);
string a = "album=" + myAlbum.AlbumTitle.ToString() + " album_id=" + myAlbum.Id.ToString() + " no_of_photos=" + myAlbum.NumPhotos.ToString();
album_id = myAlbum.Id.ToString();
album_name = myAlbum.AlbumTitle.ToString();
}
Uri postUri = new Uri(PicasaQuery.CreatePicasaUri(name, album_id));
System.IO.FileInfo fileInfo = new System.IO.FileInfo("D:\\1.bmp");
System.IO.FileStream fileStream = fileInfo.OpenRead();
PicasaEntry entry = (PicasaEntry)service.Insert(postUri, fileStream, "image/bmp","1");
fileStream.Close();
/* PhotoQuery photos = new PhotoQuery();
PicasaFeed picasaFeed = null;
photos.Uri = new Uri(PicasaQuery.CreatePicasaUri(name, album_name)); //service is a PicasaService object, with credentials set
picasaFeed = (PicasaFeed)service.Query(photos);
Uri postUri = new Uri(picasaFeed.Post);
//PicasaEntry entry = service.Insert(postUri, new MemoryStream(bFile), "image/jpeg", fileUpload.FileName) as PicasaEntry; // save the file at picasa*/
}
catch (AuthenticationException authE)
{
MessageBox.Show(authE.Message, "Falied in uploading",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
catch (Exception errE)
{
MessageBox.Show(errE.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
/// <summary>
/// /////////login id /////////////////////////////
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
///
private void authenticateUser(string username, string password, string name)
{
try
{
PicasaService myPicasa = new PicasaService("Qualitas-test");
myPicasa.setUserCredentials(username, password);
}
catch (AuthenticationException authE)
{
MessageBox.Show(authE.Message, "Invalid username/password",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
catch (Exception errE)
{
MessageBox.Show(errE.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
private void upload_Click(object sender, RoutedEventArgs e)
{
authenticateUser("
[email protected]
", "livehappy", "rjgowth11");
addnewalbum("title", "Text", "rjgowth11");
//uploading_image("rjgowth11");
}
private void addnewalbum(string title, string Text, string username)
{
try
{
//AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(username));
// PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
AlbumEntry newAlbum = new AlbumEntry();
newAlbum.Title.Text = title;
newAlbum.Summary.Text = Text;
AlbumAccessor ac = new AlbumAccessor(newAlbum);
//set to "private" for a private album
ac.Access = "private";
PicasaEntry newEntry = (PicasaEntry)service.Insert(myPicasaFeed, newAlbum);
/* AlbumEntry newEntry = new AlbumEntry();
newEntry.Title.Text = title;
newEntry.Summary.Text = Text;
AlbumAccessor ac = new AlbumAccessor(newEntry);
//set to "private" for a private album
ac.Access = "private";
Uri feedUri = new Uri(PicasaQuery.CreatePicasaUri(username));
PicasaEntry newAlbum = (PicasaEntry)service.Insert(feedUri, newEntry);*/
// PicasaEntry createdEntry = (PicasaEntry)service.Insert(feedUri, newEntry);*/
/*AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(username));
PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
AlbumEntry Entry = new AlbumEntry();
Entry.Title.Text = title;
Entry.Summary.Text = Text;
PicasaEntry newEntry = (PicasaEntry)service.Insert(myPicasaFeed,Entry);*/
///////////////////////////error in uploading///////////////////////////////////////
// ?kind=album;
/* AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri(username));
PicasaFeed myPicasaFeed = service.Query(myAlbumQuery);
/* PicasaEntry newEntry = (PicasaEntry)service.Insert(myPicasaFeed, newAlbum);*/
/* FeedQuery query = new FeedQuery("http://picasaweb.google.com/data/feed/api/user/" + "rjgowth11" + "?kind=album");
AtomFeed calFeed = service.Query(query);*/
////////////////////////////////////////////////////////////////////////////////////////
}
catch (Exception errE)
{
MessageBox.Show(errE.Message, "Error",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
}
}
////////////////////////////////////////////////////////////////////
Attachment:
picasa_upload.rar
Reply
Answers (
3
)
How to get starting in Software Devloping
Active/active cluster in Windows server 2012