title: AWS S3 need to generate pre-signed url for GET via wcf to return to classic asp request form
body: <p>I need to create a WCF web service that takes a request from a classic ASP page/form and returns a pre-signed expiring URL in AWS S3. (I have a little WCF experience. I've previously been able to return a custom JSON formatted object.)</p>
  
  <p>Now, I need to take a form post, get the name of the file requested from the form, and generate a pre-signed URL that expires in 24 hours, and return it.
  FYI, I don't do theory well. I need code examples.</p>
  
  <p>How to I massage the following to do what I need it to?</p>
  
  <p><a href="https://stackoverflow.com/questions/4469074/serving-videos-from-amazon-s3">Serving videos from Amazon S3</a>
  (this seems to be close to what I need. I can convert from VB to C# on my own, I just need more than this snippet to understand the total flow.</p>
  
  <p>===SampleRestService.svc.cs===</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.ServiceModel;
  using System.Text;
  using System.Data.SqlClient;
  using System.Configuration;
  
  namespace WcfService5
  {       
      [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
      public class SampleRestService : ISampleRestService
      {       
          public IEnumerable&lt;APIContentObject&gt; GetAllUsers()
          {
              IList&lt;APIContentObject&gt; myAPIContentObject = new List&lt;APIContentObject&gt;();
  
              string strcon = ConfigurationManager.ConnectionStrings["iOSConn"].ConnectionString;
  
              using (SqlConnection conn = new SqlConnection(strcon))
              {
                  conn.Open();
                  string cmdStr = String.Format("SELECT  FirstName, LastName, Email, pword, SignUpDate, enabled FROM Users");
                  SqlCommand cmd = new SqlCommand(cmdStr, conn);
                  SqlDataReader rd = cmd.ExecuteReader();
  
                  if (rd.HasRows)
                  {
                      while (rd.Read())
                      {
                          myAPIContentObject.Add(new APIContentObject(rd["FirstName"].ToString(),
                                                                      rd["LastName"].ToString(),
                                                                      rd["Email"].ToString(),
                                                                      rd["pword"].ToString(),
                                                                      rd["SignUpDate"].ToString(),
                                                                      rd["enabled"].ToString(),
                                                                      rd["FirstName"].ToString()));                                                                         
                      }
                  }
                  conn.Close();
              }
              return myAPIContentObject;
          }    
      }
  
      [DataContract]
      public class APIContentObject
      {
          [DataMember]
          public string Name { get; set; }
          [DataMember]
          public string Excerpt { get; set; }
          [DataMember]
          public string Content { get; set; }
          [DataMember]
          public string ImageURL { get; set; }
          [DataMember]
          public string ThumbnailURL { get; set; }
          [DataMember]
          public string SluggedURL { get; set; }
          [DataMember]
          public string FileURL { get; set; }
  
          public APIContentObject(string vName, string vExcerpt, string vContent, string vImageURL, string vThumbnailURL, string vSluggedURL, string vFileURL)  //, decimal sal)
          {
              Name = vName;
              Excerpt = vExcerpt;
              Content = vContent;
              ImageURL = vImageURL;
              ThumbnailURL = vThumbnailURL;
              SluggedURL = vSluggedURL;
              FileURL = vFileURL;
          }
  
      }   
  }
  </code></pre>
  
  <p>====iSampleRestService.cs====</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.ServiceModel;
  using System.Text;
  using System.ServiceModel.Web;
  
  namespace WcfService5
  {   
      [ServiceContract]
      public interface ISampleRestService
      {
          [OperationContract]
          //attribute for returning JSON format
          [WebGet(ResponseFormat = WebMessageFormat.Json,
              RequestFormat = WebMessageFormat.Xml,
              BodyStyle = WebMessageBodyStyle.Bare,
              UriTemplate = "/json/users")]
          //method
          IEnumerable&lt;APIContentObject&gt; GetAllUsers();              
      }
  }
  </code></pre>
  
  <p>====web.config====</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;connectionStrings&gt;
      &lt;add name="iOSConn" connectionString=" Server=HIDDEN;Database=HIDDEN;User ID=HIDDEN;Password=HIDDEN;Trusted_Connection=False;"/&gt;
    &lt;/connectionStrings &gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
  
      &lt;services&gt;
        &lt;service name="WcfService5.SampleRestService"&gt;
          &lt;endpoint address="/" behaviorConfiguration="REST" binding="webHttpBinding"
            bindingConfiguration="" contract="WcfService5.ISampleRestService" /&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
            contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
  
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="REST"&gt;
            &lt;webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name=""&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
  
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
  
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>