Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Service sends a .txt or .xls but not a .gz (Zipped file)
    text
    copied!<p>I have a WCF service up and running which saves a file to my server. I have tested this by sending a <code>.txt</code> file and a <code>.xls</code> file. The size of the <code>.xls</code> file is 90kb. </p> <p>Now I have a zipped file <code>.gz</code> that is only 70KB in size but when trying to complete this operation I get </p> <blockquote> <p>The remote server returned an unexpected response: (400)<br> Bad Request.</p> </blockquote> <p>When I have tried to search for this Bad Request most results lead to the fact that a large file is being sent and that I need to change the settings in the config file.</p> <p>This is not the reason in my case as the <code>.gz</code> file is smaller than the <code>.xls</code> file!</p> <p>Does anyone have any idea why this type of file cannot be sent the same as a text or Excel file???</p> <p>Edit: Code Added</p> <p>Here is the method to call the service</p> <pre><code> string name = "New Doc"; string file = @"C:/Users/Admin/Desktop/fileZipped.gz"; string ext = file.Split('.')[1]; Stream stream = File.OpenRead(file); byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); stream.Close(); var uploadFileServiceClient = new UploadFileServiceClient(); uploadFileServiceClient.UploadFile(name, bytes, ext); </code></pre> <p>And here is my service:</p> <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class UploadFileService : IUploadFileService { public bool UploadFile(string name, byte[] bytes, string extension) { string importDir = ConfigurationSettings.AppSettings["UploadFileDir"]; if (String.IsNullOrEmpty(importDir)) return false; if (!Directory.Exists(importDir)) return false; string outputFile = Path.Combine(importDir, Guid.NewGuid() + "." + extension); string filename = outputFile.Split('\\')[2]; using (StreamWriter sw = new StreamWriter(outputFile)) { sw.WriteLine(bytes); sw.Flush(); sw.Close(); } return true; } } </code></pre> <p>Like I say it works for text or Excel files.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload