Description
Issue Description
When a file is uploaded from the Dashboard for a Class with a File column, the saved filename is different to what Parse.com produces and consequently the client applications such as the Dashboard displays a truncated version of the filename.
Steps to reproduce
- Open Dashboard and create a new class (i.e. Customer). Add a column of type File. (i.e. LicenseFile)
- Add a record. Double click on the cell for the File type column and upload a File. (i.e. LICENSE.txt)
- After the upload is complete, note the name of the file in the cell. (NSE.txt)
- Now use CURL to read the record:
curl -X GET -H "X-Parse-Application-Id: 00000" -H "X-Parse-Master-Key: 11112" -H "Content-Type: application/json" http://localhost:1337/parse/Classes/Customer
Result is:
{
"results": [
{
"LicenseFile": {
"__type": "File",
"name": "fcb209ccfab5b87912c61cd32b2ac47f_LICENSE.txt",
"url": "http://localhost:1337/parse/files/00000/fcb209ccfab5b87912c61cd32b2ac47f_LICENSE.txt"
},
"createdAt": "2016-07-27T23:46:07.763Z",
"objectId": "9BDB1sc6gj",
"updatedAt": "2016-07-27T23:46:07.763Z"
}
]
}
Note the filename: fcb209ccfab5b87912c61cd32b2ac47f_LICENSE.txt
- Create the same class in Parse.com app and use CURL to get the object.
Result is:
{
"results": [
{
"LicenseFile": {
"__type": "File",
"name": "tfss-59be62cc-7cc0-4aec-9618-ecb2df31f734-LICENSE.txt",
"url": "http://files.parsetfss.com/6eb5be43-2dfb-4dd7-8297-358c52aa8260/tfss-59be62cc-7cc0-4aec-9618-ecb2df31f734-LICENSE.txt"
},
"createdAt": "2016-07-19T02:01:31.133Z",
"objectId": "oAwS5kjYZe",
"updatedAt": "2016-07-27T01:40:03.467Z"
}
]
}
Note the filename: tfss-59be62cc-7cc0-4aec-9618-ecb2df31f734-LICENSE.txt
As you can see, the random string prefix in the Parse.com version has got the dashes.
When the Dashboard reads the name value, it uses an offset (i.e. 37 or 42 depending on whether the filename starts with tfss- or not) to extract the original uploaded filename. Because of the missing dashes, this results in a truncated filename for display.
The display issue can be easily fixed in the Dashboard, but it is best fixed in the Server as other clients such as Mobile apps using the SDKs are probably experiencing the same issue.
Expected Results
filename: LICENSE.txt
Actual Outcome
filename: NSE.txt
Environment Setup
- Server
- parse-server version: 2.2.16
- Operating System: OSX 10.11.5
- Hardware: MacBook Pro 2.8GHz Core i7
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost
- Database
- MongoDB version: 3.2.4
- Storage engine: wiredTiger
- Hardware: MacBook Pro 2.8GHz Core i7
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Localhost
Logs/Trace
You can turn on additional logging by configuring VERBOSE=1 in your environment.
Not applicable
Suggested Fix
One fix would be to save the files with dashes in the filename. I have tested this and seems to work. Happy to send a PR for review.