如何将批量数据上传到解析后端

问题描述 投票:0回答:1

我正在开发一个基本上像墙纸应用程序的应用程序。 我想使用Parse作为后端。 如何创建不同的类别,并向每个类别上传大量文件? 我尝试一次一次手动上传一个文件,但是文件太多了,很麻烦。

ios parse-platform wallpaper
1个回答
0
投票

如果您的墙纸对象位于数组中,则可以这样进行:

for(wallPaper *wallpaper in someArray) {

        PFObject *wallpaper = [PFObject objectWithClassName:@"wallpaper"];
        wallpaper[@"title"]=wallpaper.title;
        UIImage *image = wallpaper.image;
        NSData *imageData = UIImageJPEGRepresentation(image, 1);
        PFFile *imageFile = [PFFile fileWithName:@"wallpaper.jpg" data:imageData];
        [imageFile saveInBackground];
        [wallpaper setObject:imageFile forKey:@"wallpaperImage"];
        [wallpaper saveInBackground];


    }

您也可以有一个单独的类“类别”。 “类别”中的每个对象都有类别名称,即“ beaches”,然后有一个PFRelation “成员”,指向哪些墙纸属于该类别。

© www.soinside.com 2019 - 2024. All rights reserved.