Hello,
Any one knows how to get back a single Photo in Stream? My attempt
below generates two exceptions within the stream object.
--------Exceptions within Stream object got back from
picasaService--------------------
Length = 'stream.Length' threw an exception of type
'System.NotSupportedException'
Position = 'stream.Position' threw an exception of type
'System.NotSupportedException'
--------- Code used to retrieve a single photo in
stream--------------------------------
// Build picasa album Query for photo
FeedQuery query = new FeedQuery(PicasaQuery.CreatePicasaUri
(Username, albumName, photoId));
string photoURI = query.Uri.ToString();
photoURI = Regex.Replace(photoURI, "feed", "entry");
// Get the photo
Stream stream = _picasaService.Query(new Uri(photoURI));
photoURI = "http://picasaweb.google.com/data/feed/api/user/zhu.chen.uk/
album/CityOfZhuHai/photoid/5268680361842240290"
Notice that it is //"/data/entry/" instead of "/data/feed/". The
username, albumName and photoId have correct values, and the album is
set to public.
I am using http Handler to render my photos, but by using the code
above i just couldn't get the Photo displayed in my http img control.
( I have tried to bind the Photo to asp:Image by using
Image3.ImageUrl = entry.Media.Content.Attributes["url"].ToString();
but some how the asp:Image just don't like it and it shows only a
"SubmitQuery"....I have no idea why....)
Please advice...
Many Thanks
Chen
--------- The Handler.ashx -----------------
Stream stream = null;
if (context.Request.QueryString["photoId"] != null &&
context.Request.QueryString["photoId"] != "")
{
photoId = context.Request.QueryString["photoId"];
albumName = context.Request.QueryString["albumName"];
stream = PhotoManager.GetPhotoStream(albumName, photoId);
} else {
albumName = context.Request.QueryString["albumName"];
//stream = PhotoManager.GetFirstPhoto(albumID, size);
}
// Get the photo from the database, if nothing is returned, get
the
default "placeholder" photo
if (stream == null) stream = PhotoManager.GetDefaultPhotoStream
();
// Write image stream to the response stream
const int buffersize = 1024 * 16;
byte[] buffer = new byte[buffersize];
int count = stream.Read(buffer, 0, buffersize);
while (count > 0) {
context.Response.OutputStream.Write(buffer, 0, count);
count = stream.Read(buffer, 0, buffersize);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Picasa-Data-API?hl=en
-~----------~----~----~----~------~----~------~--~---