Skip to content
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

Uploaded filenames are getting saved with incorrect prefix #2415

Closed
lama-buddy opened this issue Jul 28, 2016 · 4 comments
Closed

Uploaded filenames are getting saved with incorrect prefix #2415

lama-buddy opened this issue Jul 28, 2016 · 4 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@lama-buddy
Copy link
Contributor

lama-buddy commented Jul 28, 2016

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

@jeacott1
Copy link

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.

@jeacott1
Copy link

jeacott1 commented Aug 4, 2016

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?

@hramos
Copy link
Contributor

hramos commented Sep 6, 2016

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?

@hramos hramos added the type:bug Impaired feature or lacking behavior that is likely assumed label Sep 6, 2016
flovilmart pushed a commit that referenced this issue Sep 17, 2016
* increased filename length to 36 to make sure clients display correct filename

* increased filename length to 36 to make sure clients display correct filename

* added uuid prefix to saved filenames
@flovilmart
Copy link
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
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

4 participants