我们可以使用 iOS 和 Android 的 Abode Creative SDK 在 Adob​​e Assets 中上传照片吗?

Can we upload photos in Adobe Assets using Abode Creative SDK for iOS and Android?

使用此代码块仅用于访问我的 iOS 项目中的 Adob​​e 文件,但如何将我的图片上传到 Adob​​e 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");
 }];

您可以在此处找到有关如何使用 CreativeSDK 从 Creative Cloud 上传和下载文件的教程: 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);
                   }];
}