2015-02-06 1 views
1

iOS 프로젝트의 Adobe 파일에 액세스 할 때만이 코드를 사용하지만 Adobe Assets 클라우드에서 사진을 업로드하고 저장하려면 어떻게해야합니까?iOS 및 Android 용 Abode Creative SDK를 사용하여 Adobe Assets에서 사진을 업로드 할 수 있습니까?

[[AdobeUXAssetBrowser sharedBrowser]popupFileBrowser:^(AdobeSelectionAssetArray *itemSelections) { 
    NSLog(@"Selected a file"); 
    for(id item in itemSelections) { 

     AdobeAsset *it = ((AdobeSelectionAsset *)item).selectedItem; 

     NSLog(@"File name %@", it.name); 
    [_statuslabel setText:fileDesc]; 

     //If an image, let's draw it locally 
     NSString *fileType = ((AdobeAssetFile *)it).type; 
     if([fileType isEqualToString:@"image/jpeg" ] || [fileType isEqualToString:@"image/png" ]) { 
      NSLog(@"Going to download the image"); 
      [((AdobeAssetFile *)it) getData:NSOperationQueuePriorityHigh 
           onProgress:^(double fractionCompleted) { 
           } 
           onCompletion:^(NSData *data, BOOL fromcache) { 
            NSLog(@"Done downloaded"); 
            UIImage *preview = [UIImage imageWithData:data]; 
           } 
          onCancellation:^(void){ 

          } 
            onError:^(NSError *error) { 

            } 
      ]; 

     } 

    } 
} onError:^(NSError *error) 
{ 
    //do nothing 
    NSLog(@"Error"); 
}]; 

답변

1

업로드하고 여기에 CreativeSDK를 사용하여 크리에이티브 클라우드에서 파일을 다운로드하는 방법에 대한 자습서를 찾을 수 있습니다 는 https://creativesdk.adobe.com/docs/ios/#/articles/files/index.html

파일 업로드를 다루는 특정의 코드는 다음과 같습니다 :

NSData *imgData = UIImageJPEGRepresentation(yourImage, 0.8f); 

NSString *dataPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"foo.jpg"]; 
NSURL *dataURL = [NSURL fileURLWithPath:dataPath]; 

NSError *err; 
BOOL success = [imgData writeToFile:dataPath options:NSDataWritingAtomic error:&err]; 

if (success) { 

    AdobeAssetFolder *root = [AdobeAssetFolder getRootOrderedByField:AdobeAssetFolderOrderByName orderDirection:AdobeAssetFolderOrderDescending]; 

    [AdobeAssetFile create:@"foo.jpg" 
        inFolder:root 
       withDataPath:dataURL 
        withType:kMimeTypeJPEG 
     withCollisionPolicy:AdobeAssetFileCollisionPolicyAppendUniqueNumber 
       onProgress:^(double fractionCompleted) { 
        NSLog(@"Percent complete %f", fractionCompleted); 
       } 
       onCompletion:^(AdobeAssetFile *file) { 
        NSLog(@"Uploaded"); 
       } 
      onCancellation:nil 
        onError:^(NSError *error) { 
         NSLog(@"error uploading %@", error); 
        }]; 
} 
관련 문제