Pierre-Olivier Latour 11 years ago
parent
commit
c8c34aa61f
2 changed files with 5 additions and 3 deletions
  1. 3 1
      Mac/main.m
  2. 2 2
      Tests/HTMLFileUpload/002-200.response

+ 3 - 1
Mac/main.m

@@ -278,7 +278,9 @@ int main(int argc, const char* argv[]) {
           }
           }
           for (GCDWebServerMultiPartFile* file in [(GCDWebServerMultiPartFormRequest*)request files]) {
           for (GCDWebServerMultiPartFile* file in [(GCDWebServerMultiPartFormRequest*)request files]) {
             NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file.temporaryPath error:NULL];
             NSDictionary* attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:file.temporaryPath error:NULL];
-            [string appendFormat:@"%@ = &quot;%@&quot; (%@ | %llu KB)<br>", file.controlName, file.fileName, file.mimeType, attributes.fileSize / 1000];
+            [string appendFormat:@"%@ = &quot;%@&quot; (%@ | %llu %@)<br>", file.controlName, file.fileName, file.mimeType,
+                                 attributes.fileSize >= 1000 ? attributes.fileSize / 1000 : attributes.fileSize,
+                                 attributes.fileSize >= 1000 ? @"KB" : @"Bytes"];
           };
           };
           NSString* html = [NSString stringWithFormat:@"<html><body><p>%@</p><hr>%@</body></html>", string, formHTML];
           NSString* html = [NSString stringWithFormat:@"<html><body><p>%@</p><hr>%@</body></html>", string, formHTML];
           return [GCDWebServerDataResponse responseWithHTML:html];
           return [GCDWebServerDataResponse responseWithHTML:html];

+ 2 - 2
Tests/HTMLFileUpload/002-200.response

@@ -1,9 +1,9 @@
 HTTP/1.1 200 OK
 HTTP/1.1 200 OK
 Cache-Control: no-cache
 Cache-Control: no-cache
-Content-Length: 443
+Content-Length: 447
 Content-Type: text/html; charset=utf-8
 Content-Type: text/html; charset=utf-8
 Connection: Close
 Connection: Close
 Server: GCDWebServer
 Server: GCDWebServer
 Date: Fri, 25 Apr 2014 14:15:21 GMT
 Date: Fri, 25 Apr 2014 14:15:21 GMT
 
 
-<html><body><p>secret = 42<br>files = &quot;hero_mba_11.jpg&quot; (image/jpeg | 106 KB)<br>files = &quot;Test File.txt&quot; (text/plain | 0 KB)<br></p><hr>           <form name="input" action="/" method="post" enctype="multipart/form-data">           <input type="hidden" name="secret" value="42">           <input type="file" name="files" multiple><br/>           <input type="submit" value="Submit">           </form>         </body></html>
+<html><body><p>secret = 42<br>files = &quot;hero_mba_11.jpg&quot; (image/jpeg | 106 KB)<br>files = &quot;Test File.txt&quot; (text/plain | 21 Bytes)<br></p><hr>           <form name="input" action="/" method="post" enctype="multipart/form-data">           <input type="hidden" name="secret" value="42">           <input type="file" name="files" multiple><br/>           <input type="submit" value="Submit">           </form>         </body></html>