开发者

how can be possible to programmatically upload and retrieve photos from PicasaWeb in C#

开发者 https://www.devze.com 2023-04-08 14:27 出处:网络
Is it possible to use PicasaWeb to host photos for my website? My requirement to upload and access with开发者_Python百科in my ASP.NET Website.Yes, technically. You can use the Picasa Web Albums Data A

Is it possible to use PicasaWeb to host photos for my website? My requirement to upload and access with开发者_Python百科in my ASP.NET Website.


Yes, technically. You can use the Picasa Web Albums Data API to access the metadata about your images and then display them from Picasa. For an album, this is not a horrible idea, but I would not use this method for your site graphics.


    public string UploadImage(byte[] imageBytes_, string imageName_)
    {
        string url = string.Empty;
        try
        {
            PicasaEntry newPhoto = null;
            MemoryStream ms = new MemoryStream();
            ms.Write(imageBytes_, 0, imageBytes_.Length);
            if (_albumFeed != null)
            {
                PicasaEntry photoEntry = new PhotoEntry();
                photoEntry.MediaSource = new Google.GData.Client.MediaFileSource(ms, imageName_, "image/jpeg");

                newPhoto = this._service.Insert<PicasaEntry>(new Uri(this._albumFeed.Post), photoEntry);
            }

            url = newPhoto.FeedUri;

        }
        catch (Exception ex)
        {
            throw new DneException("Error while uploading photo", ex );
        }

        return url ;
    }

I am uploading a zipped images and extracting using SharpZipLib library. I am getting each file in chunk of bytes and which I am converting into MemoryStream later to pass the MediaSource object. I am getting 400 Bad Request error each time. When I am passing FileStream, it works fine but doesn't work with MemoryStream

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号