Skip to content

[Feature] Differentiate between chunked and regular uploads when fetching headers for process endpointΒ #1041

@Sopamo

Description

@Sopamo

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

I'm the author of https://github.com/sopamo/laravel-filepond and am currently working on a feature that allows users to use Azure's special "append only" blob type.
For this, I need to know the content-type of the file when initialising the blob. I initialize the blob when /process is called on the server. Each PATCH call with the chunk data then just appends the chunk data to the append only blob.
I can set the content type in the headers function like this:

{
  url: api.getURL("/filepond/api"),
  process: {
    url: "/process",
    headers: (file: File) => {
      return { ...defaultHeaders, "Upload-Name": file.name, "Content-Type": file.type }
    },
    withCredentials: true,
  },
  patch: {
    url: "/?patch=",
    headers: defaultHeaders,
    withCredentials: true,
  },
  revert: {
    url: "/process",
    headers: defaultHeaders,
    withCredentials: true,
  },
}

This works perfectly when uploading chunks.

The issue is, that when not uploading chunks (e.g. when the file is smaller than chunkSize, this doesn't work, because it will override the Content-Type of the request that uploads the full file, which is an issue, because for regular multipart uploads the content type needs to be multipart/form-data; boundary=----WebKitFormBoundary...

I could not find a way to differentiate between chunked uploading and non-chunked uploading in the headers function.

Describe the solution you'd like

One solution would be to add the type of upload to the metadata that is passed as a second parameter to the headers function? Or passing in a third parameter with the upload type to the headers function.

Are there any other obvious solutions I'm missing that might not even require a code change in filepond?
I'd be open to creating a PR with a solution if you have a preferred way of implementing it - even knowing that v5 is right around the corner (maybe, hopefully :) )

Describe alternatives you've considered

A workaround is currently to force chunking, but that's not ideal of course.

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