parse-server-s3-adapter icon indicating copy to clipboard operation
parse-server-s3-adapter copied to clipboard

Returning wrong file name

Open danielsanfr opened this issue 4 years ago • 2 comments
trafficstars

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 https://github.com/parse-community/parse-server-s3-adapter/pull/117.

danielsanfr avatar Feb 02 '21 21:02 danielsanfr

Thanks for reporting.

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

mtrezza avatar Feb 04 '21 00:02 mtrezza

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
      });
    });
  }

aliasad106 avatar Aug 12 '22 13:08 aliasad106