Bläddra i källkod

1.上传新接口

huangxiaodong 1 år sedan
förälder
incheckning
86db3cdcd5

+ 34 - 2
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+upLoadFile.m

@@ -89,6 +89,8 @@
                                 return;
                             }
                             
+                            self.curUploadPostion = [fileLengthNum longValue];
+                            
                             if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
                                 [self beginGotoUploadImageFun:fileLengthNum];
                             }
@@ -243,6 +245,7 @@
                         fileLengthNum = data[@"fileLenth"];
                     }
                     
+                    self.curUploadPostion = [fileLengthNum longValue];
                     [self handleUploadingFun:fileLengthNum];
                 }
                  else if ([status isEqualToString:@"2"]) {
@@ -324,6 +327,11 @@
 #pragma mark 处理上传过程
 - (void)handleUploadingFun:(NSNumber*)fileLengthNum
 {
+    //异常处理
+    if(fileLengthNum.longValue < 0)
+    {
+        return;
+    }
     
     BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular)];
     
@@ -470,6 +478,24 @@
     return [NSData dataWithBytes:result length:sizeof(result)];
 }
 
+// long转NSData
+- (NSData *)long2Data:(long)i{
+    Byte b0 = i & 0xff;
+    Byte b1 = i >> 8 & 0xff;
+    Byte b2 = i >> 16 & 0xff;
+    Byte b3 = i >> 24 & 0xff;
+    Byte b4 = i >> 32 & 0xff;
+    Byte b5 = i >> 40 & 0xff;
+    Byte b6 = i >> 48 & 0xff;
+    Byte b7 = i >> 56 & 0xff;
+    
+    // 有大小端模式问题?
+    //Byte result[] = {b0, b1, b2, b3};
+    //Byte result[] = {b3, b2, b1, b0};
+    Byte result[] = {b7, b6, b5,b4,b3, b2, b1, b0};
+    return [NSData dataWithBytes:result length:sizeof(result)];
+}
+
 // short转NSData
 - (NSData *)short2Data:(short)i{
     Byte b0 = i & 0xff;
@@ -509,7 +535,8 @@
     
     //msgType
     //unsigned char msgType = 12;
-    unsigned char msgType = 15;
+    //unsigned char msgType = 15;
+    unsigned char msgType = 20;
     NSData *msgTypeData = [NSMutableData dataWithBytes:&msgType length:sizeof(msgType)];
     //HLog(@"msgTypeData:%@",msgTypeData);
     
@@ -526,7 +553,7 @@
     
     
     //curNum
-    int curNum = (int)self.indexOfUploadFlie;
+    int curNum = (int)self.indexOfUploadFlie + 1;
     //NSData *curNumData = [NSData dataWithBytes:&curNum length:sizeof(curNum)];
     NSData * curNumData = [self int2Data:curNum];
     //HLog(@"curNumData:%@",curNumData);
@@ -537,6 +564,10 @@
     NSData * totalNumData = [self int2Data:totalNum];
     //HLog(@"totalNumData:%@",totalNumData);
     
+    long Postion = self.curUploadPostion;
+    //long Postion = 100000000000;
+    NSData * PostionData = [self long2Data:Postion];
+    HLog(@"PostionData:%@",PostionData);
 
     NSMutableData *checkBCCData = [NSMutableData new];
     [checkBCCData appendData:msgTypeData];
@@ -544,6 +575,7 @@
     [checkBCCData appendData:datalenData];
     [checkBCCData appendData:curNumData];
     [checkBCCData appendData:totalNumData];
+    [checkBCCData appendData:PostionData];
     [checkBCCData appendData:curData];
     
     long length = [curData length];

+ 1 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h

@@ -121,6 +121,7 @@
 @property (nonatomic, assign) NSInteger cutFileEachPieceSzie;
 @property (nonatomic, strong) uploadFileDataModel *curUploadFileDataMod;
 @property (nonatomic, assign) BOOL isSuspendUploadType;
+@property (nonatomic, assign) long curUploadPostion;//当前上次片的位置
 
 //备份文件用到
 @property (nonatomic, copy) NSString * _Nullable backupsTaskUid;

+ 6 - 2
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -759,10 +759,14 @@ ComontAlretViewControllerDelegate>
                 HLog(@"\n-----摇一摇成功------");
             }else if ([messageType isEqualToString:@"keyboardFeedbackBean"]){/*调起键盘*/
                 [weakSelf keyboardFeedbackBeanFun];
-            }else if ([messageType isEqualToString:@"FileRandomReady"]){/*申请文件上传得到答复*/
+            }else if ([messageType isEqualToString:@"FileRandomReady"]
+                      ||[messageType isEqualToString:@"FilePartReady"]
+                      ){/*申请文件上传得到答复*/
                 [weakSelf applyUploadFileServiceResponseFun:dataDict];
             }
-            else if ([messageType isEqualToString:@"uploadFileRandomRet"]){/*文件上传得到答复*/
+            else if ([messageType isEqualToString:@"uploadFileRandomRet"]
+                     ||[messageType isEqualToString:@"uploadFilePartRet"]
+                     ){/*文件上传得到答复*/
                 [weakSelf upLoadFileFunServiceResponseFun:dataDict];
             }
             else if ([messageType isEqualToString:@"backUpFileRandomReady"]){/*文件备份得到答复*/

+ 2 - 1
创维盒子/双子星云手机/CloudPlayer/RCCommandHelp.m

@@ -995,7 +995,8 @@
     
     NSString*savePath = [[NSString alloc] initWithFormat:@"%@%@",uploadDefaultPath,filePath];
     
-    NSString *dataStr =[NSString stringWithFormat:@"{\"data\":{\"taskUid\":\"%@\",\"filePath\":\"%@\",\"savePath\":\"%@\"},\"type\":\"uploadFileRandom\"}",taskUid,filePath,savePath];
+    //NSString *dataStr =[NSString stringWithFormat:@"{\"data\":{\"taskUid\":\"%@\",\"filePath\":\"%@\",\"savePath\":\"%@\"},\"type\":\"uploadFileRandom\"}",taskUid,filePath,savePath];
+    NSString *dataStr =[NSString stringWithFormat:@"{\"data\":{\"taskUid\":\"%@\",\"filePath\":\"%@\",\"savePath\":\"%@\"},\"type\":\"uploadFilePart\"}",taskUid,filePath,savePath];
     
     if (USENEWCONTROLLCOMMONDNO500)
     {