瀏覽代碼

RA Image

上传任务保存文件相对路径
Ray Zhang 9 年之前
父節點
當前提交
0bbd74dbd5

二進制
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 3 - 1
RA Image/RA Image/PopModeViewController.m

@@ -84,7 +84,9 @@
         NSMutableDictionary* task=[[NSMutableDictionary alloc]init];
         
     
-        task[@"file_path"]=photo[@"path"];
+        task[@"path"]=photo[@"path"];
+        task[@"file"]=photo[@"path"];
+
         task[@"url"]=Appdelegate.address;
         NSString *md5 = [photo objectForKey:@"md5"];
         

+ 3 - 3
RA Image/RA Image/UploadViewController.m

@@ -110,7 +110,7 @@
         
         double progress =[item_json[@"progress"] doubleValue];
         cell.progress=progress;
-        cell.name=[item_json[@"file_path"] lastPathComponent];
+        cell.name=item_json[@"file"];
         cell.state=  status;
         
         RAUploadOperation* op = item_json[@"operation"];
@@ -141,9 +141,9 @@
             }
             double progress =[item_json[@"progress"] doubleValue];
             cell.progress=progress;
-            cell.name=[item_json[@"file_path"] lastPathComponent];
+            cell.name=item_json[@"file"];
             cell.state=  status;
-            //               cell.labelname.text=[item_json[@"file_path"] lastPathComponent];
+            
             
         };
         //

+ 13 - 2
common/upload/RAUploadManager.m

@@ -8,6 +8,7 @@
 #import <UIKit/UIKit.h>
 #import "RAUploadManager.h"
 #import "NetworkUtils.h"
+#import "RAUtils.h"
 
 @implementation RAUploadManager
 
@@ -86,7 +87,7 @@
         
         [self stopTask:task];
         NSError* error = nil;
-        [fmanager removeItemAtPath:task[@"file_path"] error:&error];
+        [fmanager removeItemAtPath:[self filePath:task] error:&error];
     }
     [[self mutableArrayValueForKey:@"arr_queue"] removeObjectsInArray:tasks];
 //    if (self.delegate && [self.delegate respondsToSelector:@selector(uploadManager:didRemoveTasks:)]) {
@@ -100,7 +101,7 @@
     //    [self.arr_queue addObject:task];
     [self stopTask:task];
     NSError* error = nil;
-    [fmanager removeItemAtPath:task[@"file_path"] error:&error];
+    [fmanager removeItemAtPath:[self filePath:task] error:&error];
     
     [[self mutableArrayValueForKey:@"arr_queue"] removeObject:task];
 //    if (self.delegate && [self.delegate respondsToSelector:@selector(uploadManager:didRemoveTasks:)]) {
@@ -109,6 +110,16 @@
     
     
 
+}
+
+
+-(NSString*)filePath:(NSMutableDictionary*)task
+{
+    
+    NSString *path = [RAUtils appCacheDirectory];
+    path= [path stringByAppendingPathComponent:task[@"path"]];
+    path= [path stringByAppendingPathComponent:task[@"file"]];
+    return path;
 }
 -(void) stopTask:(NSMutableDictionary*) task
 {

+ 10 - 1
common/upload/RAUploadOperation.m

@@ -10,6 +10,7 @@
 #import "NetworkUtils.h"
 #import <UIKit/UIKit.h>
 #import "AppDelegate.h"
+#import "RAUtils.h"
 
 @interface RAUploadOperation ()
 {
@@ -83,7 +84,7 @@
     
     __block NSMutableDictionary* block_task = _taskinfo;
     
-    [NetworkUtils upload:_taskinfo[@"file_path"]  Params:_taskinfo[@"params"] ToHost:_taskinfo[@"url"] Result:^(NSMutableDictionary *result) {
+    [NetworkUtils upload:[self filePath:_taskinfo ]  Params:_taskinfo[@"params"] ToHost:_taskinfo[@"url"] Result:^(NSMutableDictionary *result) {
         
         int r=[result[@"result"] intValue];
         if(r==2)
@@ -147,6 +148,14 @@
   //  [self didChangeValueForKey:@"isExecuting"];
 }
 
+-(NSString*)filePath:(NSMutableDictionary*)task
+{
+
+    NSString *path = [RAUtils appCacheDirectory];
+    path= [path stringByAppendingPathComponent:task[@"path"]];
+    path= [path stringByAppendingPathComponent:task[@"file"]];
+    return path;
+}
 //- (void)completeOperation {
 ////    [self willChangeValueForKey:@"isFinished"];
 ////    [self willChangeValueForKey:@"isExecuting"];