Переглянути джерело

Wifi:added Wifi-Download from iOS Devices

Carola Nitz 11 роки тому
батько
коміт
d4ab3eaef3
3 змінених файлів з 79 додано та 7 видалено
  1. 14 2
      Resources/web/index.html
  2. 41 5
      Resources/web/style.css
  3. 24 0
      Sources/VLCHTTPConnection.m

Різницю між файлами не показано, бо вона завелика
+ 14 - 2
Resources/web/index.html


+ 41 - 5
Resources/web/style.css

@@ -147,34 +147,70 @@ div.main.drop {
   cursor: pointer;
 }
 
-.message {
+.messageUpload {
   margin: 100px 0px;
 }
-.message h1 {
+.messageUpload h1 {
   font-size: 30px;
   font-weight: bold;
   text-align: center;
   text-shadow: 1px 1px 2px black;
   line-height: 60px;
 }
-.message p {
+.messageUpload p {
   text-align: center;
   text-shadow: 1px 1px 2px black;
 }
 
+.messageDownload {
+  margin: 50px 0px;
+}
+.messageDownload h1 {
+  font-size: 30px;
+  font-weight: bold;
+  text-align: center;
+  text-shadow: 1px 1px 2px black;
+  line-height: 60px;
+}
+.messageDownload p {
+  text-align: center;
+  text-shadow: 1px 1px 2px black;
+}
+
+.files {
+  text-align: left;
+  margin-left: 20px;
+  text-shadow: 1px 1px 2px black;
+  line-height: 30px;
+}
+
 .uploads li {
   height: 80px;
   padding: 0 20px;
   position: relative;
 }
-.uploads li:nth-child(2n) {
+.uploads li:nth-child(2n),
+.downloads li:nth-child(2n) {
   background-color: rgba(0,0,0,0.2);
 }
-.uploads .filename {
+.uploads .filename,
+.downloads li {
   font-size: 20px;
   line-height: 50px;
   text-align: left;
 }
+.downloads a {
+    line-height: 25px;
+    height: 18px;
+    color: white;
+}
+
+.downloads li {
+    height: 40px;
+    padding: 0 20px;
+    position: relative;
+}
+
 .uploads .progress {
   height: 20px;
   border: 0px solid white;

+ 24 - 0
Sources/VLCHTTPConnection.m

@@ -20,6 +20,7 @@
 #import "HTTPFileResponse.h"
 #import "MultipartMessageHeaderField.h"
 #import "VLCHTTPUploaderController.h"
+#import "HTTPDynamicFileResponse.h"
 
 @interface VLCHTTPConnection()
 {
@@ -95,7 +96,30 @@
         // let download the uploaded files
         return [[HTTPFileResponse alloc] initWithFilePath: [[config documentRoot] stringByAppendingString:path] forConnection:self];
     }
+    if ([path hasPrefix:@"/download/"]) {
+        NSString *filePath = [[path stringByReplacingOccurrencesOfString:@"/download/" withString:@""]stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+        return [[HTTPFileResponse alloc] initWithFilePath:filePath forConnection:self];
+    }
+    NSString *filePath = [self filePathForURI:path];
+    NSString *documentRoot = [config documentRoot];
+    NSString *relativePath = [filePath substringFromIndex:[documentRoot length]];
+
+    if ([relativePath isEqualToString:@"/index.html"])
+    {
+        NSArray *allFiles = [MLFile allFiles];
+        NSString *fileList = @"";
+        for (MLFile *file in allFiles) {
+            NSString *fileHTML = [NSString stringWithFormat:@"<li><a href=\"download/%@\" download>%@</a></li>",[file.url stringByReplacingOccurrencesOfString:@"file://"withString:@""], file.title];
+            fileList = [fileList stringByAppendingString:fileHTML];
+        }
 
+        NSMutableDictionary *replacementDict = [NSMutableDictionary new];
+        [replacementDict setObject:fileList forKey:@"FILES"];
+        return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
+                                                   forConnection:self
+                                                       separator:@"%%"
+                                           replacementDictionary:replacementDict];
+    }
     return [super httpResponseForMethod:method URI:path];
 }