gpt4 book ai didi

ios - 将图像上传到解析

转载 作者:行者123 更新时间:2023-12-01 18:53:55 27 4
gpt4 key购买 nike

我正在尝试为我在 Parse 中的用户上传图像作为 PFFile。我没有收到任何错误,但文件不存在?我究竟做错了什么?

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
self.imageToUpload = info[UIImagePickerControllerOriginalImage];
self.profileImageView.image = self.imageToUpload;

NSData *pictureData = UIImagePNGRepresentation(self.imageToUpload);

PFFile *image = [PFFile fileWithName:@"img" data:pictureData];
[image saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
PFUser *user = [PFUser currentUser];
user[@"picture"] = image;
[picker dismissViewControllerAnimated:YES completion:nil];
}
else {
[[[UIAlertView alloc] initWithTitle:@"Error" message:[error userInfo][@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
} progressBlock:^(int percentDone) {
NSLog(@"Uploaded: %d%%", percentDone);
}];
}

最佳答案

您实际上并没有保存 user ,因此不会建立用户和新文件之间的链接。这使文件漂浮在周围,没有连接到任何东西。

基本上,保存 user设置后[@"picture"] = image .

关于ios - 将图像上传到解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29148161/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com