tags:

views:

1315

answers:

4

I want to write a simple utility to upload images to various free image hosting websites like TinyPic or Imageshack via a right-click context menu for the file.

How can I do this using .NET? I've seen some linux scripts that use cURL to post images to these website but I'm not sure how I could create the post request, complete with an image in C#?

Can someone point me in the right direction?


EDIT:

I've found a pretty good resource. Cropper, a free screenshot tool written in .net, has a lot of open-source plugins. One of them is a SendToTinyPic.. complete with source. Link here:
http://www.codeplex.com/cropperplugins

+3  A: 

Use HttpWebRequest.

Using this class, you can POST data to a remote HTTP address, just set the mime/type to multi-part/form encoded, and post the binary data from the image with the request.

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.71).aspx

FlySwat
+1  A: 

The FlickrNet API makes this extremely easy for working with Flickr from .NET. You have to have a Flickr account as well as an API key and shared secret. Once you have what you need, working with the API is very simple:

// http://www.flickr.com/services/api/misc.api_keys.html
string flickrApiKey = "<api key>";
string flickrApiSharedSecret = "<shared secret>";
string flickrAuthenticationToken = "<authentication token>";

Flickr flickr = new Flickr( flickrApiKey, flickrApiSharedSecret );

flickr.AuthToken = flickrAuthenticationToken;    

foreach ( FileInfo image in new FileInfo[] { 
    new FileInfo( @"C:\image1.jpg" ), 
    new FileInfo( @"C:\image2.jpg" ) } )
{
    string photoId = flickr.UploadPicture(
        image.FullName, image.Name, image.Name, "tag1, tag2" );
}
Jeff Hillman
+1  A: 

For ImageShack, take a look to this Application.

CMS
A: 
Cheeso