Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Can't upload a file that doesn't exist locally." when saving PFObject with no PFFile #766

Closed
GabrielMSharp opened this issue Jan 16, 2016 · 40 comments

Comments

@GabrielMSharp
Copy link

Saving ANY PFObject currently gives Error 151, irrespective of whether that PFObject has a PFFile, unsaved or not. I think this is generally linked to the Localdatastore and is a development on the issue I posted here: #763

@nlutsenko
Copy link
Contributor

This sounds very strange, as error 151 is thrown only in 2 places, either when you are trying to download a file that was never saved to the server or when a file download was cancelled on saving an object.
Not sure, but doesn't look like you are hitting any of these. Any chance you can attach a code sample/project that can reproduce the issue?

@parse-github-bot
Copy link

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

@parse-github-bot
Copy link

This issue has not been updated for 7 days. If you have additional information to help pinpoint this issue as an SDK bug, please comment on this issue. We will close this issue in 7 days if no additional information is provided. Thank you for your feedback.

@JasonPan
Copy link

JasonPan commented Feb 1, 2016

I've got the Parse server running locally and I'm getting the same issue:

Error saving Error Domain=Parse Code=151 "Can't upload a file that doesn't exist locally." UserInfo={error=Can't upload a file that doesn't exist locally., NSLocalizedDescription=Can't upload a file that doesn't exist locally., code=151}

@ghost
Copy link

ghost commented Feb 1, 2016

I'm getting the same issue after migrating to Parse Server (Heroku/MongoLab) as well.

@danieleng
Copy link

Also having the same issue after migration to Parse Server. Was working just fine before.

@juancruzmdq
Copy link

I have the same issue after migrating to Parse Server (Heroku with MongoLab addOn), this happen when I try to save the user profile with:
"[[PFUser currentUser] saveInBackgroundWithBlock:...]"

When I try to save another object I have this error:
"[Error]: Object not found. (Code: 101, Version: 1.12.0)"

All ACL perms seems to be ok, and was working fine before migration

@toboklee
Copy link

toboklee commented Feb 3, 2016

I ran into this problem after migration....

To fix the problem, find all the columns that use PFFile.
Then, in the database retrieve the files manually and need to upload again...

For me, it was happening due to profile images, so I saved the images locally; then, used

UIImage *tmp = [UIImage imageNamed:@"Image you saved"];
PFFile *file = [PFFile fileWithData:UIImageJPEGRepresentation(tmp, 1.0f)];

[[PFUser currentUser] setObject:file forKey:@"key"];
[[PFUser currentUser] saveInBackground];

After that, problem was gone.

@mamoun1101
Copy link

@toboklee Can you elaborate more about how did you solve this problem, what do you mean by retrieve the files manually in the database ( I have the same issue)

@topwebtek7
Copy link

@toboklee
Thanks for sharing how to fix this issue.

But I can't fix this issue with your method.

Here is my code.
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"add_photo"], 0.8f);
PFFile *userPhoto = [PFFile fileWithName:@"avatar.png" data:imageData];
[currentUser setObject:userPhoto forKey:@"photo"];
[currentUser saveInBackground];

I received same message,
[Error]: Can't upload a file that doesn't exist locally. (Code: 151, Version: 1.12.0)

Looking for hearing from you.

Thanks

@CommunityLabsLoca
Copy link

I'm getting this issue when I save an object that has a pointer to a PFUser. If I save everything but the pointer, the object saves. But once I add [LKFActivity setObject:[PFUser currentUser] forKey:@"activityUser" ] then I get the error message: Can't upload a file that doesn't exist locally. (Code: 151, Version: 1.12.0). I just realized that if I delete the current user's profile picture, then I don't get the error message. Thus, I think my issue is exactly the same as what you all are facing, but I'm still not clear how to fix it?

@topwebtek7
Copy link

Actually, my development is on migration parse server.(Heroku)

Here is my original code.
[currentUser setValue:@"YES" forKey:PF_USER_ONLINE_STATUS]; [currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (!error) { NSLog(@"Success!"); } else [ProgressHUD showError:error.localizedDescription Interaction:YES]; }];
After migration, this code does not work. That's why I got error message "Can't upload a file that doesn't exist locally.".

Before migration, this code works very well.

I don't know why this issue occurs.

Also I am working on XCode 7.2/iOS 9.2

@topwebtek7
Copy link

I am working on migration parse.

So I could migrate Parse DB to MongoDB using MongoLab.
Also I could change parse-server-example;

add cloud code(for mandrill-api and twilio) in main.js.(this works very well)
deploy to Heroku.
However, I have some issues here.

On iOS development side, when the user logs in, app don't progress any PFObject.

if I am going to change user's profile(string, boolean, image and so on), I get error message
[Error]: Can't upload a file that doesn't exist locally. (Code: 151, Version: 1.12.0)

If I am going to download the user's photo, I get error message.
[Error]: Can't download a file that doesn't exist on the server or locally. (Code: 151, Version: 1.12.0)

Also I found a strange issue.
After migration, I created a new account on my app.(without user's photo)
First, it seems it works very well

But If I upload user's photo, connection error occurs.

What's matter?

I hope you can help me.

Thanks

@toboklee
Copy link

toboklee commented Feb 9, 2016

Hmm...
Double check if the file is in fs.file _collection in MongoDB.
Also, you have to check with fs.chunks to make sure that the binary data is available.

@topwebtek7
Copy link

@toboklee
Thanks a lot

I don't know what fs.file and fs.chunks are.

Here are the screenshots of them

mongodb

fs chunks

fs file

Please explain in more detail.

@juancruzmdq
Copy link

Any one tried turning failIndexKeyTooLong to False? I can't do it, because I have a freeplan in mongolab
db.runCommand( { setParameter: 1, failIndexKeyTooLong: false } )

@toboklee
Copy link

@otto1020
can you try it again with parse-server 2.0.8?

@michaelbina
Copy link

I just upgraded to parse-server 2.0.8 and am still seeing this issue. Has anyone found a good solution to this yet?

@ghost
Copy link

ghost commented Feb 18, 2016

Nope

@michaelbina
Copy link

If it helps anyone that is still looking into this issue, here is a screenshot of the call stack and error details when I'm getting this:

screen shot 2016-02-18 at 10 09 26 pm

This happens consistently when I'm trying to upload to parse-server hosted on Heroku with a MongoLabs database. I've seen it when creating a new object in a class and uploading an image to one of the fields and also seen it when creating an object that has an image field that I'm not setting on creation. This seems to be a widespread issue when calling saveInBackgroundWithBlock on new objects.

@mikhailb1990
Copy link

This issue occurs even with the 'save()' method, not just the saveInBackground() methods...so annoying. >:( No idea what to do

@dcdspace
Copy link

I have this problem too, and now I can't update any user info because of it. Everything worked fine before moving over to the server.

@danieleng
Copy link

I still have this issue. Parse Server on Heroku/Mongolab.
If a user object has a file stored in it (in my case image files), it´s not possible to save the user object and I get this error message:
"Error Domain=Parse Code=151 "Can't upload a file that doesn't exist locally.".

It is possible to fix the issue temporarily by deleting the image files manually through the database. Then I can also add new files through my apps interface and everything works like a charm again.
Until I log out of the application. If I do that and try to log in again, the error reoccurs with the same error message.

Any ideas?

@michaelbina
Copy link

Glad to know I'm not the only one having this issue. It's stopped me from moving forward with my transition onto Heroku/Mongolab for the time being. I even went through the process of deleting all of the data in the classes which were getting this issue and that seemed to solve it for a bit until I later uploaded files again to those classes and it would come back and not go away.

It seems this is an issue with classes that have at least one optional PFFile column in them. The code may be expecting a file but not getting one.

I've identified that the only place this error can be called is in PFFileController.m at line 216:

if (!sourceFilePath) { NSError *error = [PFErrorUtilities errorWithCode:kPFErrorUnsavedFile message:@"Can't upload a file that doesn't exist locally."]; return [BFTask taskWithError:error]; }

I believe that should be called when a value for a PFFile is present, but it is still being called for me when no file is uploaded for a field so it's getting to this point erroneously.

@nlutsenko - I know this isn't a set of reproducible steps (I'll work on that) but do you have any ideas here? It seems this a problem for multiple people now.

@dcdspace
Copy link

I think Parse is coming out with a file migrator tool to move files from their S3 bucket to your own, so I'm hoping this is a GridStore problem. This also is stopping me from continuing development on my Parse Server, as the app cannot function until this is fixed.

I've found that if you upload a new file on Parse Server to Gridstore, it will only be visible to other clients checking from the server, which isn't great for legacy users. Longterm plan is to store everything in S3, but this needs to get fixed first for that to work.

@michaelbina
Copy link

I set up my parse server to store files on my own S3 bucket instead of gridstore and am still having this issue so I'm not sure that is going to fix it.

@dcdspace
Copy link

Thanks for letting me know, I haven't used the S3 adapter yet but hoped it would fix it, guess not. Not sure how to fix this now...

@michaelbina
Copy link

I'm now seeing this happening on my device only and not in simulator with the same code and similar input. Not sure what the main variables are that might make a difference there. Any ideas?

@nlutsenko
Copy link
Contributor

Hey everyone, we found few places where this was happening in Parse-Server.
The fixes are in place right now for few things (like /users/login) and one more fix is incoming in parse-community/parse-server#637

All of this means that the fix is going to come out very soon (likely this week) and after you upgrade your Parse Server - it will be ultimately fixed.

@ghost
Copy link

ghost commented Feb 24, 2016

Awesome!

@nlutsenko
Copy link
Contributor

Hey guys,

Parse-Server 2.1.3 is out, and includes fixes for this issue.
Please upgrade your server, test it and comment here if this still reproduces for you.
Be aware, that if you had a cached File somewhere on the client - you might want to refresh that cache, since the URLs might be missing in it.

@dcdspace
Copy link

@nlutsenko It works thank you so much! A small problem though is that when uploading new files to Mongolab's Gridstore, older clients not connected to the new Parse Server cannot access them. They are displayed as .bin in the Parse Dashboard and they say "Access Denied" when clicking on them in the dashboard.

I haven't tried the S3 adapter yet but am planning on switching to it, would that solve the problem? Thanks.

@CommunityLabsLoca
Copy link

I know this is a really dumb question, but could you explain how to update to Parse Server 2.1.3 or direct me to an explanation? I have MongoLabs and Heroku set up, but I don't know how updating works.
Thank you!

Also a tutorial on the S3 adapter would be really helpful if one exists!

@michaelbina
Copy link

run:

'npm update'

from your root directory to update your libraries. Make sure you don't have a hardcoded version set up in package.json.

Here is the manual for S3 adapter: https://github.com/ParsePlatform/parse-server/wiki/Storing-Files-in-AWS-S3

@ryderjack
Copy link

@nlutsenko I've updated Parse Server to 2.1.4 but still seeing this error when saving a PFFile
Can't upload a file that doesn't exist locally. (Code: 151, Version: 1.12.0)

Any suggestions?

@ghost
Copy link

ghost commented Mar 7, 2016

@ryderjack initially updating didn't work for me either until I created a new project with the server from scratch (instead of just updating via npm).

@juancruzmdq
Copy link

I think that you have to update some come in your index.js file

var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey',
fileKey: 'optionalFileKey',
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed
});

I had to add this two lines

fileKey: 'optionalFileKey',
serverURL: 'http://localhost:1337/parse' // Don't forget to change to https if needed

@lkf20
Copy link

lkf20 commented Mar 25, 2016

Sorry for my delay - thanks @michaelbina for the help! (From CommunityLabsLoca)

@Skyb0rg
Copy link

Skyb0rg commented Jan 22, 2019

I had the same issue today with localdatastore. only remove and new Install of the app was the solution.
if i tried to save any pfobject -> code 151.
getting local results -> none
internet results readable.
writing new or updating pfobject with user Pointer -> Error 151 Can't upload a file that doesn't exist locally.

@koyinusa
Copy link

Hi @Skyb0rg Were you able to get a fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests