Objective c 服务器和桌面目标mac os之间的同步文件夹
我有一个要连续同步文件夹的项目:Objective c 服务器和桌面目标mac os之间的同步文件夹,objective-c,amazon-s3,synchronization,Objective C,Amazon S3,Synchronization,我有一个要连续同步文件夹的项目: 文件夹\u服务器在服务器上 文件夹\u桌面在我的mac系统上 我想在运行时同步这两个文件夹 以下是我正在执行的步骤: 来自服务器的数据:字典数组,包含:文件名、修改日期、文件大小 本地数据:字典数组,包含:文件名、修改日期、文件大小 比较文件名 若文件不存在,它将被复制到相应的文件夹中 如果文件同时存在于两个文件夹中,则会检查修改日期时间,并修改具有先前日期(较低日期)的文件 逻辑如下: -(void)get_localfile{ } -(void)get
在服务器上文件夹\u服务器
在我的mac系统上文件夹\u桌面
-(void)get_localfile{
}
-(void)get_serverfile{
}
-(void)Compare_Files{
//Upload FILES
for(int i=0;i<[Array_LocalFiles count];i++){
if(![Array_serverobjects containsObject:[Array_LocalFiles objectAtIndex:i]]){
//Upload to server
}else{
NSMutableDictionary *dic=[[NSMutableDictionary alloc] init];
for(int j=0;j<[arr_Dict_server count];j++){
if([[[arr_Dict_server objectAtIndex:j]valueForKey:@"file"] isEqualToString:[Array_LocalFiles objectAtIndex:i]]){
NSLog(@"file==server file=>%@",[[arr_Dict_server objectAtIndex:j]valueForKey:@"file"]);
NSLog(@"file==local file=>%@",[[arr_Dict_Localfile objectAtIndex:i]valueForKey:@"file"]);
dic=[arr_Dict_server objectAtIndex:j];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"];
NSDate *date_server = [dateFormat dateFromString:[dic valueForKey:@"timestamp"]];
NSDate *date_local = [dateFormat dateFromString:[[arr_Dict_Localfile objectAtIndex:i] valueForKey:@"timestamp"]];
if ( [date_server timeIntervalSinceDate:date_local] == 0) {
// //NSLog(@"Dates are equal.no action perform");
}
if ( [date_server laterDate:date_local] == date_local ) {
//NSLog(@"%@ file upload to server",[Array_LocalFiles objectAtIndex:i]);
}
if ( [date_server laterDate:date_local] == date_server) {
//NSLog(@"%@ file dowloaded from server",[dic valueForKey:@"file"]);
}
break;
}
}
}
}
//download FILES
for(int i=0;i<[Array_serverobjects count];i++){
if(![Array_LocalFiles containsObject:[Array_serverobjects objectAtIndex:i]]){
//NSLog(@"%@ file dowloaded from server",[Array_serverobjects objectAtIndex:i]);
}
}
}
-(void)获取本地文件{
}
-(void)获取服务器文件{
}
-(void)比较\u文件{
//上传文件
对于(int i=0;iAs)作为替代方案,您可以使用来自的aws s3 sync
命令。@JohnRotenstein我想通过编码来执行此操作。