Trying to save a profile photo picture during registration and it keeps showing this… Any idea why? I’m currently using your backendless demos to learn. In the folder “FileService,” the upload works fine. Everything’s implemented in the registerviewcontroller but it isn’t working.
-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
if ([identifier isEqualToString:@"Register.RegisterViewController"]) {
self.registration = nil;
NSLog(@"SEND ------> registering: name = %@, password = %@, verify = %@", self.nameInput.text, self.passwordInput.text, self.verifyPasswordInput.text);
if ([self.nameInput.text length] && [self.passwordInput.text length] && [self.passwordInput.text isEqualToString:self.verifyPasswordInput.text])
{
self.registration = [Registration new];
self.registration.name = self.nameInput.text;
self.registration.password = self.passwordInput.text;
self.registration.email = self.emailInput.text;
self.registration.birthday = [NSDate date];
self.registration.gender = self.maleChoice.selected ? MALE_GENDER_VAL : FEMALE_GENDER_VAL;
@try {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
if (_isUpload)
{
[backendless.fileService remove:[NSString stringWithFormat:@"profile/%@", [[self.registration.path pathComponents] lastObject]]];
// [backendless.persistenceService remove:[Registration class] sid:self.registration.objectId];
self.registration.path = nil;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Image has been deleted" delegate:nil cancelButtonTitle:@"Done" otherButtonTitles:nil];
[alert show];
}
else
{
#if 1 // image file
NSString *fileName = [NSString stringWithFormat:@"profile/%0.0f.jpeg",[[NSDate date] timeIntervalSince1970] ];
#if 1 // use saveFile method
BackendlessFile *uploadFile = [backendless.fileService saveFile:fileName content:UIImageJPEGRepresentation(self.mainImage, 0.1)];
#else // use upload method
BackendlessFile *uploadFile = [backendless.fileService upload:fileName content:UIImageJPEGRepresentation(self.mainImage, 0.1)];
#endif
#else // binary array file (test)
const char myByteArray[] = {0x12,0x23,0x34,0x45,0x56,0x67,0x78,0x89,0x12,0x23,0x34,0x45,0x56,0x67,0x78,0x89};
NSData *data = [NSData dataWithBytes:myByteArray length:sizeof(myByteArray)];
BackendlessFile *uploadFile = [backendless.fileService saveFile:@"binary101.bin" content:data overwriteIfExist:YES];
#endif
self.registration.path = uploadFile.fileURL;
}
_isUpload = !_isUpload;
}
@catch (Fault *fault)
{
NSLog(@"ImageViewController -> upload: FAULT = %@", fault);
[self showAlert:fault.message];
}
// server invoke
BackendlessUser *user = [BackendlessUser new];
user.email = self.registration.email;
user.password = self.registration.password;
user.name = self.registration.name;
// [user setProperty:LOGIN_PROFILE_KEY object:user.email];
// [user setProperty:BIRTHDATE_PROFILE_KEY object:self.registration.birthday];
[user setProperty:GENDER_PROFILE_KEY object:self.registration.gender];
[user setProperty:IMAGE_PROFILE object:self.registration.path];
// test "\n"
//[user setProperty:@"music" object:@"TEST\nline1\nline2\n"];
NSLog(@"SEND ------> registering: user = %@", user);
if ([self userRegister:user]) {
return YES;
}
}
return NO;
}
return YES;
}