Skip to content

Uploaded filenames are getting saved with incorrect prefix #2415

Closed

Description

@lama-buddy

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

  1. Open Dashboard and create a new class (i.e. Customer). Add a column of type File. (i.e. LicenseFile)
  2. Add a record. Double click on the cell for the File type column and upload a File. (i.e. LICENSE.txt)
  3. After the upload is complete, note the name of the file in the cell. (NSE.txt)
  4. 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

  1. 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.

Related Issue

Pull Request

Activity

  1. jeacott1 commented on Jul 29, 2016

    @jeacott1

    a possible alternate fix might be to provide a user configurable option to include/exclude the '-' dashes that make the code look like a uuid.

  2. jeacott1 commented on Aug 4, 2016

    @jeacott1

    folks, this is a bigger issue than just a truncated name in the dashboard.
    any app relying on the file format to retrieve the filename (and I bet there are many) will be impacted by this.

    can we get some consensus on a direction forward please?

  3. hramos commented on Sep 6, 2016

    @hramos
    Contributor

    The issue raised here seems quite clear and I'm inclined to agree it should be fixed in Parse Server. Can you submit a PR?

  4. added
    type:bugImpaired feature or lacking behavior that is likely assumed
    on Sep 6, 2016
  5. flovilmart commented on Sep 18, 2016

    @flovilmart
    Contributor

    Closing as released part of 2.2.20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions