Skip to content

Incorrect filename with file upload through REST API post-migration #2491

Closed
@anuchandra

Description

@anuchandra

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!

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!

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

  1. Upload two files with the 2 code snippets above
  2. Associate the files with a record in a class as above
  3. 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

Logs/Trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions