Skip to content

feat: Support useMasterKey in Parse.File.getData() #10428

@mtrezza

Description

@mtrezza

New Feature

Description

Parse.File.getData() currently does not support useMasterKey or any authentication option. It always performs a plain HTTP fetch to the file URL without any auth headers.

This becomes a problem when the fileDownload server option is configured to restrict file downloads (e.g. enableForAuthenticatedUser: false). In that case, there is no SDK-level way to download a file with master key privileges — neither from Cloud Code nor from any server-side context.

Current Behavior

  • Parse.File.getData() performs a plain fetch(url) with no authentication
  • The fileDownload restriction blocks the request if file downloads are disabled
  • There is no option to pass useMasterKey: true or any other auth option

Proposed Solution

Add support for useMasterKey in getData():

const data = await file.getData({ useMasterKey: true });

When useMasterKey: true is passed in a server-side (Cloud Code) context, Parse Server should resolve the file through the files adapter directly (e.g. filesAdapter.getFileData(filename)) instead of making an HTTP request to the file URL. This approach:

  1. Bypasses the fileDownload HTTP restriction internally, similar to how useMasterKey works for queries and other operations
  2. Avoids sending master key credentials over HTTP, which would be problematic when file URLs point to external services (e.g. S3, CloudFront)
  3. Is consistent with the existing useMasterKey pattern used across the Parse SDK

Alternatives Considered

  • Sending master key headers in the HTTP request: Risky because file URLs may point to external services (S3, CloudFront), which would leak credentials to third-party domains.
  • Workaround with raw fetch and manual headers: Works but requires consumers to manage trusted origin checks and credential handling themselves, which is error-prone.

Environment

  • Parse Server: any version with fileDownload support
  • Parse JS SDK: current

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions