title: Uploading large files from android to c# WCF Rest Service
body: <p>i am developing an android application where i can upload video,audio and images from android device to WCF REST Service. it is uploading a video file of 10MB size perfectly, but when i tried to upload a video file of <strong>1GB</strong> it is not uploading to server. i want to make an application where i can upload a file size upto <strong>3gb to 4gb</strong>.how can i achieve this can anyone  please guide me to achieve this scenario.</p>
  
  <p><strong>wcf Service Code :</strong>  </p>
  
  <pre><code>public string PostImage(Stream stream)
          {
  MultipartParser parser = new MultipartParser(stream);
  
              if (parser.Success)
              {
                  string fileName = parser.Filename;
                  string contentType = parser.ContentType;
                  byte[] fileContent = parser.FileContents;
                  FileStream fileToupload = new FileStream("D:\\FileUpload\\" + fileName, FileMode.Create);
                  fileToupload.Write(fileContent, 0, fileContent.Length);
                  fileToupload.Close();
                  fileToupload.Dispose();
                  stream.Close();
                  return "Success !!!";
              }
              else
              {
                  return "Exception!!!";
              }
          }
  </code></pre>
  
  <p><strong>web.config file:</strong></p>
  
  <pre><code>&lt;configuration&gt;
  
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="Upload.Service1" behaviorConfiguration="default"&gt;
          &lt;endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="RestBinding" name="Service1" contract="Upload.IService1" /&gt;
        &lt;/service&gt;   
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="web"&gt;
            &lt;webHttp/&gt;
          &lt;/behavior&gt; 
        &lt;/endpointBehaviors&gt;
  
        &lt;serviceBehaviors&gt;
          &lt;behavior name="default"&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
  
            &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
        &lt;webHttpBinding&gt;
          &lt;binding name="RestBinding"  maxReceivedMessageSize="2147483647"  maxBufferSize="2147483647"&gt;
            &lt;readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="544096" /&gt;
            &lt;security mode="None"&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
  
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;protocolMapping&gt;
          &lt;add binding="basicHttpsBinding" scheme="https" /&gt;
      &lt;/protocolMapping&gt;    
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;!--
          To browse web app root directory during debugging, set the value below to true.
          Set to false before deployment to avoid disclosing web app folder information.
        --&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>My Android Code:</strong></p>
  
  <pre><code>        HttpClient httpclient = new DefaultHttpClient();
          HttpPost httpost = new HttpPost("http://192.169.3.34/Service1.svc/upload");
          MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
          entity.addPart("fileContents", new FileBody(new File("/mnt/sdcard/hi.mp4")));
          httpost.setEntity(entity);
          HttpResponse response;
          response = httpclient.execute(httpost);
  </code></pre>
  
  <p>i am getting the status code as 404 when i tried to upload a file of 1GB.</p>
  
  <p>where i need to do changes to  make my code to upload a file size of 2gb to 5gb. can anyone please help me out in solving the issue.</p>