Getting a 'Metadata part too large' error when uploading video

Our organization has troubles when uploading the video after its successful staging phase. We keep getting the ‘Metadata part too large’ error when uploading videos usually larger than 4mb. We found this issue: https://community.shopify.com/c/graphql-basics-and/getting-quot-metadata-part-is-too-large-quot-from-uploading-bulk/td-p/1759204 , but it doesn’t work for us since we are providing the file name in our FormData object. Here is a snippet of our code in C#:

This problem started appearing couple of days ago, and since we have a large user database, it is affecting the organization. Is there a way we can fix this or maybe a workaround that can be used?

I had to deal with this issue today and I finally figured it out.

First of all, as people mentioned in this StackOverflow thread, “filename” parameter must be set in “Content-Disposition” header for files larger than 4MB. MultipartFormDataContent.Add(HttpContent content, string name, string fileName) method overload called in your code does this, however, there are two more conditions:

  • “filename” parameter value must be enclosed in double quotes.
  • “filename*” parameter (also added by this method overload) is not tolerated and must be removed.

Lastly, as mentioned in the current version of Shopify API documentation, “file” part must be the last in the multipart form.

My code that prepares multipart form content looks like this:

var uploadFormContent = new MultipartFormDataContent();
foreach (var parameter in uploadTarget.parameters)
{
    uploadFormContent.Add(new StringContent(parameter.value!), parameter.name!);
}
await using var fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read);
uploadFormContent.Add(new StreamContent(fileStream), "file", "\"" + Path.GetFileName(filePath) + "\"");
uploadFormContent.Last().Headers.ContentDisposition!.FileNameStar = null;

With this code I was able to upload files ~15MB in size.