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

Returning wrong file name #140

Open
danielsanfr opened this issue Feb 2, 2021 · 2 comments
Open

Returning wrong file name #140

danielsanfr opened this issue Feb 2, 2021 · 2 comments

Comments

@danielsanfr
Copy link
Contributor

Assuming the following configuration:

new ParseServer({
    preserveFileName: true,
    filesAdapter: {
        module: '@parse/s3-files-adapter'.
        options: {
            directAccess: false,
            validateFilename(filename: string) { return null }
        }
})

And that it has a file saved with the following name: folder/bar-bar.jpg.

When I retrieve the file URL, the getFileLocation function returns: https://<MOUNT_PATH>/files/<APP_ID>/folder/bar-bar.jpg. However, this URL causes the parse-server to return an error: HTTP 403 - {"error":"unauthorized"}

The correct URL that should be returned is: https://<MOUNT_PATH>/files/<APP_ID>/folder%2Fbar-bar.jpg

I would like to know how you would like to solve this problem? Since the response may behave differently when directAccess is true or false.

Note: I encountered this problem while doing some tests with my PR #117.

@mtrezza
Copy link
Member

mtrezza commented Feb 4, 2021

Thanks for reporting.

To clarify, do you want to use the adapter with directAccess: true or false?

@aliasad106
Copy link

generate key is called after the file url gets generated by getFileLocation

 const location = this.adapter.getFileLocation(config, filename);
    return this.adapter.createFile(filename, data, contentType, options).then(() => {
      return Promise.resolve({
        url: location,
        name: filename
      });
    });
  }

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