Uploading to Youtube with ASP.Net

Being looking into the google API for uploading to youtube and found the following bit of code. It does require you to upload the video to your server first so will add this to the CMS so clients can approve the video and have it uploaded to their account.

Dim settings As YouTubeRequestSettings
Dim request As YouTubeRequest
Dim developerKey As String = "AI39si6SO"
settings = New YouTubeRequestSettings("Youtube uploader", developerKey, "username", "password")
request = New YouTubeRequest(settings)
Try

Dim newVideo As Video = New Video()
newVideo.Title = "Sample Movie"
newVideo.Tags.Add(New MediaCategory("Sample", YouTubeNameTable.CategorySchema))
newVideo.Keywords = "hangover, funny"
newVideo.Description = "Hangover"
newVideo.YouTubeEntry.Private = True
newVideo.Tags...

Read More

HTML to WORD export in ASP.NET

Just completed a simple export of html to Microsoft word using OpenXML. I first tried using the Office COMs but found out that you need Office installed on the server for it to work so the below saved me!

http://html2openxml.codeplex.com/SourceControl/latest

Read More

Secure loading of PDF’s in ASP.NET

Use the base controllers File method.

 

public ActionResult Image(string id)
{
var dir = Server.MapPath("/Images");
var path = Path.Combine(dir, id + ".jpg");
return base.File(path, "image/jpeg");
}

 

As a note, this seems to be fairly efficient. I did a test where I requested the image through the controller (http://localhost/MyController/Image/MyImage) and through the direct url (http://localhost/Images/MyImage.jpg) and the results were:

LinkĀ http://stackoverflow.com/questions/186062/can-an-asp-net-mvc-controller-return-an-image

Read More