Wednesday, May 30, 2012

SSIS: How to Download images from Picasa album?

Picasa, the Google's offering of sharing, uploading and downloading images has many methods/plug-in available to upload and download images. In this post, we will learn how we can down load images from Picasa web album to our local folder through SSIS.

To start with, I have following images available in my Picasa web album "SSIS-Image-Test". We will download these images to our local folder.

Before we get our hand to SSIS we need to ensure that we have Google account, internet connectivity and we have installed the Google Data API client library for .NET.

In SSIS package at control flow; I have one component Script Task. Script task contains the .NET code logic to download the images from Picasa web album.

I have added references of Google Data API DLLs and using following name space in the script task.

using Google.GData.Client;
using Google.GData.Photos;
using Google.GData.Extensions;
using Google.GData.Extensions.Location;
using Google.Picasa;
using System.Net;

The .NET code snippet for Main function() in Script Task is following:

public void Main()
        {
 string filename;
//Download all images to this path.       
 filename="C:\\006.  Temp\\Image\\SSISImage\\DownloadImage\\";

 PicasaService myPicasa = new PicasaService("Vikash-Test-Picasa");
//Pass userid and password as the credentials
 myPicasa.setUserCredentials("abc@gmail.com", "abcpassword");

 PhotoQuery myPhotoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri("abc", "5746268939336053009"));
 PicasaFeed myPicasaFeed = myPicasa.Query(myPhotoQuery);

 foreach (PicasaEntry p in myPicasaFeed.Entries)
 {
//Create the Webclient and download file
    WebClient wc = new WebClient();
    wc.DownloadFile(p.Content.Src.ToString(),filename + p.Title.Text);
                   
    Dts.TaskResult = (int)ScriptResults.Success;
}

After setting up the code, I run the package and package completed successfully.

I checked my local folder and all images were successfully downloaded into folder.

So our objective to download images from Picasa web album is achived.

Thanks for reading this post

If you wan to explore more on Picasa with .NET; please visit Google API Series in .NET

Related Article:

Popular Posts

Real Time Web Analytics