Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
damon patron
4,692 Pointsthumbnail image saved but blank in parse
i am trying to make and save a thumbnail image from the videos i record off the self destruct app here is my code that Im using:
-
(void)uploadMessage { NSData *vidImageFileData; NSString *vidImageFileName; NSData *fileData; NSString *fileName; NSString *fileType;
// check if its a image or video if (self.image != nil) { // if image shrink it UIImage *resizedImage = [self resizeImage:self.image toWidth:320.0 andHeight:480.0]; fileData = UIImagePNGRepresentation(resizedImage); fileName = @"image.png"; fileType = @"image"; } else { fileData = [NSData dataWithContentsOfFile:self.videoFilePath]; fileName = @"video.mov"; fileType = @"video";
//UIImage *thumbnail = [self thumbnailFromVideoAtURL:self.moviePlayer.contentURL];// UIImage *thumbnail = [self currentItemScreenShot:self.moviePlayer.contentURL]; // self.thumbnailResized = [self resizeImage:thumbnail toWidth:75.0 andHeight:75.0]; vidImageFileData = UIImagePNGRepresentation(self.thumbnailResized); vidImageFileName = @"image.png"; }
// upload the file itself PFFile *file = [PFFile fileWithName:fileName data:fileData]; [file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert Alert" message:@"file cannot be saved" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show]; } else { // upload message details PFObject *message = [PFObject objectWithClassName:@"Message"]; [message setObject:file forKey:@"file"]; [message setObject:fileType forKey:@"fileType"]; [message setObject:self.recipients forKey:@"recipientsIds"]; [message setObject:[[PFUser currentUser] objectId] forKey:@"sendersIds"]; [message setObject:[[PFUser currentUser] username] forKey:@"sendersName"]; message[@"thumbnail"] = [PFFile fileWithName:vidImageFileName data:vidImageFileData]; [message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert Alert" message:@"file cannot be saved" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } else { // went well [self reset]; } }]; }
}];
}
now it is saving but when i go into parse and click on the image.png of the thumbnail it is blank what is it im doing wrong