Skip to content

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

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

Closed
4 tasks done
anuchandra opened this issue Aug 9, 2016 · 3 comments
Closed
4 tasks done

Comments

@anuchandra
Copy link

anuchandra commented Aug 9, 2016

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

@hramos
Copy link
Contributor

hramos commented Aug 9, 2016

Can you update your parse-server? v2.2.17 is the latest as of this writing. Please comment and we'll re-open if it is still an issue.

@hramos hramos closed this as completed Aug 9, 2016
@anuchandra
Copy link
Author

Apologies, I gave you an incorrect version number above.

parse-server version is 2.2.17
parse version was 1.9.0 hence the cause of confusion on my side.

I am using the latest version of the parse server in the issue above.

@flovilmart flovilmart reopened this Aug 10, 2016
@hramos
Copy link
Contributor

hramos commented Sep 6, 2016

Seems like this may be related to #2415. I'm going to consider this a duplicate unless shown otherwise.

@hramos hramos closed this as completed Sep 6, 2016
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

3 participants