title: S3 putobject throwing Invalid URI: The format of the URI could not be determined
body: <p>I'm working on uploading local files to aws s3 in C# .net, and I'm using <code>putObjectRequest</code> to make the request to aws s3, however, I've just received a thrown exception:  <code>Invalid URI: The format of the URI could not be determined.</code>. Here is what I'm doing: </p>
  
  <pre><code>try {
      string testString = @"C:\Path\to\object files\file.jpg";
      PutObjectRequest objReq = new PutObjectRequest
      {
          Key = key,
          ContentType = "JPG",
          BucketName = bucket + "/" + FolderName,
          CannedACL = S3CannedACL.PublicReadWrite,
          FilePath = testString
      };
      PutObjectResponse response = s3Client.PutObject(objReq);
  }
  catch (Exception ex) 
  {
      Console.WriteLine(ex.Message);
  }
  </code></pre>
  
  <p>I carefully checked the <code>BucketName</code>, <code>RegionEndPoint</code> and <code>ServiceURL</code>, they have been set correctly, so I'm thinking the <code>FilePath</code> is not correct. However, after searching the file path format in C#, I think I'm using the correct operator to escape the backslash. Is there any other cause can lead to this exception?</p>
  
  <p>The entire stackTrace is like this:</p>
  
  <blockquote>
    <p>at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind
    uriKind)     </p>
    
    <p>at System.Uri..ctor(String uriString)     </p>
    
    <p>at
    Amazon.Runtime.Internal.EndpointResolver.DetermineEndpoint(IClientConfig
    config, IRequest request)     </p>
    
    <p>at
    Amazon.S3.Internal.AmazonS3PostMarshallHandler.ProcessRequestHandlers(IExecutionContext
    executionContext)    </p>
    
    <p>at
    Amazon.S3.Internal.AmazonS3PostMarshallHandler.PreInvoke(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.S3.Internal.AmazonS3PostMarshallHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at Amazon.Runtime.Internal.Marshaller.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.S3.Internal.AmazonS3PreMarshallHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.S3.Internal.AmazonS3ExceptionHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at Amazon.Runtime.Internal.MetricsHandler.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.Internal.RuntimePipeline.InvokeSync(IExecutionContext
    executionContext)     </p>
    
    <p>at
    Amazon.Runtime.AmazonServiceClient.Invoke[TRequest,TResponse](TRequest
    request, IMarshaller`2 marshaller, ResponseUnmarshaller unmarshaller) </p>
    
    <p>at Amazon.S3.AmazonS3Client.PutObject(PutObjectRequest request)     </p>
    
    <p>at Camera_Capture.UploadFileToAmazonS3(String Filepath, String
    camstring, String SerialNumber) in C:\path\to\Program.cs:line 371</p>
  </blockquote>