Description
Please read the following instructions carefully.
Check out #1271 for an ideal bug report.
The closer your issue report is to that one, the more likely we are to be able to help, and the more likely we will be to fix the issue quickly!
Many members of the community use Stack Overflow and Server Fault to ask questions.
Read through the existing questions or ask your own!
- Stack Overflow: http://stackoverflow.com/questions/tagged/parse.com
- Server Fault: https://serverfault.com/tags/parse
For database migration help, please file a bug report at https://parse.com/help#report
Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!
- You've met the prerequisites: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#prerequisites.
- You're running the latest version of Parse Server: https://github.com/ParsePlatform/parse-server/releases
- You have filled out every section below. Issues without sufficient information are more likely to be closed.
- You've searched through existing issues: https://github.com/ParsePlatform/Parse-Server/issues?utf8=%E2%9C%93&q=is%3Aissue Chances are that your issue has been reported or resolved before.
Issue Description
File upload through REST API doesn't create the correct filename post migration. The filename is correct when I use api.parse.com but incorrect when I upload directly to my own hosted parse server.
This code creates a file with the name pic.jpg
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST',
'/1/files/pic.jpg',
open(lowres_image, 'rb').read(),
{
"X-Parse-Application-Id": "myid",
"X-Parse-REST-API-Key": "mykey",
"Content-Type": "image/jpeg"
})
lowres = json.loads(connection.getresponse().read())
print '--- Low res image file upload, Parse server returned:', lowres
parse_class = '/1/classes/myclass'
connection.request('POST',
parse_class,
json.dumps({
"lowres_picture": {
"name": lowres['name'],
"__type": "File"
}
}),
{
"X-Parse-Application-Id": "myid",
"X-Parse-REST-API-Key": "mykey",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
This code creates a file with the name 'jpg' and not 'pic.jpg'.
connection = httplib.HTTPConnection('myserverip', 1337)
connection.connect()
connection.request('POST',
'/parse/files/pic.jpg',
open(lowres_image, 'rb').read(),
{
"X-Parse-Application-Id": "myid",
"X-Parse-REST-API-Key": "mykey",
"Content-Type": "image/jpeg"
})
lowres = json.loads(connection.getresponse().read())
print '--- Low res image file upload, Parse server returned:', lowres
parse_class = '/parse/classes/myclass'
connection.request('POST',
parse_class,
json.dumps({
"lowres_picture": {
"name": lowres['name'],
"__type": "File"
}
}),
{
"X-Parse-Application-Id": "myid",
"X-Parse-REST-API-Key": "mykey",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
Steps to reproduce
- Upload two files with the 2 code snippets above
- Associate the files with a record in a class as above
- Inspect in Parse Dashboard.
Expected Results
One filename in the Dashboard will have the name 'pic.jpg' and the other will have 'jpg'
Actual Outcome
Incorrect filenames cause all sorts of problems in the client end.
Environment Setup
- Server
- parse-server version: 1.9.0
- Operating System: ubuntu 14.04
- Hardware: digital ocean 1gb RAM, 1 core, 30gb ssd
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Digital Ocean
- Database
- MongoDB version: v3.0.12
- Storage engine:
- Hardware:
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Digital Ocean