Monday, June 30, 2008

Retrieving a file that is stored in a database as an image.

1. Create a "File Server" as an HttpHandler
-Within the web.config, set up a page (filemanager.aspx below) that will handle http requests.

<system.web>
  <httpHandlers>
    <add verb="*" path="filemanager.aspx" type="Project.FileManagerHttpHandler, DLLName"/>
  </httpHandlers>
</system.web>

2. Within the html page, create a hyperlink to the http handler
http post to server: <a href="http://url/fileserver.aspx?uniqueIdentifier">click here</a>

3. Create the class that will handle the http request

public class FileServerHttpHandler : IHttpHandler, IRequiresSessionState
{
  // Override the ProcessRequest method.
  public void ProcessRequest(HttpContext context)
  {
    try
    {
      Guid token = new Guid(context.Request.QueryString.ToString());

      BinaryWriter bw;
      context.Response.Clear();
      using (SqlDataReader dr = SqlHelper.ExecuteReader(DBHelper.ConnectionString, "FileGetByFileToken", token))
        {
        if (dr != null)
        {
          if (dr.Read())
          {
context.Response.ContentType = dr["filetype"].ToString();
            byte[] o = (byte[]) dr["filedata"];
              bw = new BinaryWriter(context.Response.OutputStream);
              bw.Write(o);
            }
            dr.Close();
          }
        }
      }
    catch (Exception)
    {
    }
  }

  // Override the IsReusable property.
  public bool IsReusable
  {
    get { return true; }
  }

Saturday, June 28, 2008

Howard Stern on the iPhone

Thanks to the work of Millard Software (www.millardsoftware.com), iPhone owners can now enjoy Howard Stern and the rest of Sirius Satellite Radio through their iPhone!

This is how to set it up:
1. You need to have a jailbroken iPhone, this can be achieved by downloading and installing ZiPhone here.

2. Execute and install the ZiPhone jailbreak onto your iPhone

3. Add the following repository to your Installer:
http://www.millardsoftware.com/files/downloads/usirius/iphone/iphone.xml
more info: 
a. click the "installer" which will be on your homescreen
b. click on "Sources" form bottom menu
c. click on "Edit" which will be on the top right of screen
d. click on "Add" which will be on the top left of screen
e. type in the above URL


4. Select uSirius - iPhone Edition in the Multimedia section.

If you have a Sirius subscription, you enter your credentials and will have Howard Stern and Sirius Radio on your iPhone. If you don't have a subscription yet, you can receive a free three day trial by signing up at Sirius