Archive for January, 2015

Upload a file to Amazon S3 using C#

This code example is probably online a million times, but just to include it again here;

string existingBucketName = “mybucket”;
string filePath = @”c:\users\you\desktop\file.png”;
Amazon.Util.ProfileManager.RegisterProfile(“test”, “xxxxx”,”XXXX”);
AWSCredentials credentials = new StoredProfileAWSCredentials(“test”);
IAmazonS3 s3Client = new AmazonS3Client(credentials, RegionEndpoint.EUWest1);
TransferUtility fileTransferUtility = new TransferUtility(s3Client);
var uploadRequest = new TransferUtilityUploadRequest

FilePath = filePath,
BucketName = existingBucketName,
CannedACL = S3CannedACL.PublicRead

Categories: Uncategorized

Capture hi-res image from iTunes using C#

This is a quick demo of how to use the iTunes API to extract the hi-res icon of any iOS app;

WebClient wc = new WebClient();
string strUrl = @”” + HttpUtility.UrlEncode(tbSearch.Text) + “&entity=iPadSoftware”;
string strHtml = wc.DownloadString(strUrl);
const string strArtRegex = “artworkUrl100.:\”(.*?)\””;
Match mArt = Regex.Match(strHtml, strArtRegex);
string Url = mArt.Groups[1].Value;
imgArtwork.Src = Url;

This assumes a user interface somewhat like this:

<asp:TextBox runat=”server” ID=”tbSearch”></asp:TextBox>
<asp:Button runat=”server” ID=”btnSearch” OnClick=”btnSearchClick” Text=”Search”/>
<img id=”imgArtwork” runat=”server”/>

Hope this helps someone.

Categories: Uncategorized

Favourite Tweets using C# Tweetsharp

If you want to make noise on twitter, favouriting people’s tweets does draw a little attention, so I decided to try to do this automatically, to see if I could build followers.- Here is the code I used in C# (authentication details removed) – you need a reference to TweetSharp

var service = new TwitterService(“########”, “######”);
service.AuthenticateWith(“###”, “#####”);
TwitterSearchResult res = service.Search(new SearchOptions { Q = args[0], Count = 100});
IEnumerable<TwitterStatus> status = res.Statuses;
foreach (var tweet in status)
service.FavoriteTweet(new FavoriteTweetOptions{Id = tweet.Id});

It takes a command line argument, which it uses as a search term, so you can favourite tweets that are relevant.

And, hey if you want to follow me, please go to:

Categories: Uncategorized
%d bloggers like this: