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
codemonkey3
656 PointsInvalid type for key file
Hi, i'm having problem with uploading file to parse.com. Everytime i try to send an image, after a few seconds of upload, the simulator will return "Please try sending your message again" while xcode will show "Error: invalid type for key file, expected string, but got file (Code: 111, Version: 1.2.11)". The code that i use is downloaded from here:
2 Answers
codemonkey3
656 PointsFound this link that says it's basically a cloud code error but i still have no idea how to solve:
Some help please.
Amit Bijlani
Treehouse Guest TeacherSounds like it is expecting a string when it should be an image. When creating the PFObject make sure that you are setting the fileType key to image.
codemonkey3
656 PointsHi Amit, i found out the problem. The problem is due to: [message setObject:file forKey:@"file"]; If i delete that part then the code works fine but the problem is that the tutorial and the project code use it. Can you download the code from the tutorial and try to send an image to see whether you get the same error?
Ben Jakuben
Treehouse TeacherI downloaded the project code and it is working for me. That line that you reference matches what I have in my working projects. You might want to check your Parse data browser to see if your "Messages" class is somehow off. There was a bug in one of the project files (that I have since fixed) where "Messages" was incorrectly spelled as "Message".
codemonkey3
656 PointsHi Ben, i check the data browser and found that in the File column besides file is written String instead of File like in your video. How do i change that?
Ben Jakuben
Treehouse TeacherJust a guess here - maybe some other earlier piece of code uploaded a String in the "file" column? You may need to delete the "file" column and then run your app again to upload a new PFFile object and create the column appropriately.
One quick side note: This should be fairly simple in this development phase where you can change data as needed. If a change like this were needed later on (after your app were in the App Store, for example), you would need to do a more planned data migration to make sure that existing data wasn't lost or corrupted. :)
Hope this helps!
codemonkey3
656 PointsYup, that works. Thanks Ben!