#413 - Payload too large

2 messages · Page 1 of 1 (latest)

crystal dew
#

Hello. I'm trying to upload a file to Azure Blob Storage. I'm performing the server action/route handler (tried both) and it always returning 413. I changed next config to 100MB and still the same. Is there any way to get rid of this? I'm just requesting for azure storage to get blob client and then directly using api of it to send array buffer just like that:

const file = value as FileWithPath;
const { name: filename, type: contentType } = file as FileWithPath;
const url = ${getServiceUrl(process.env.BASE_API_PATH)}/files/upload-url${createQueryFromParams({ params: { filename, contentType } })};

  const response = await fetch(url, {
    headers: {
      "Content-Type": "application/json",
      Cookie: headers().get("Cookie")!
    }
  });

  const respJson: UseGetFileUploadUrlReturnType = await response.json();
  const { storageUrl, sasToken, uniqueName } = respJson;
  const blobService = new BlobServiceClient(`${storageUrl}/${sasToken}`);
  const containerClient = blobService.getContainerClient(process.env.AZURE_BLOB_SERVICE_CONTAINER_NAME);
  const blobClient = containerClient.getBlockBlobClient(uniqueName);

  const options = {
    blobHTTPHeaders: {
      blobContentType: contentType,
      blobContentDisposition: `attachment; filename=${filename}`
    }
  };

  const buffer = await file.arrayBuffer();

  try {
    await blobClient.uploadData(buffer, options);
  } catch (error) {
    console.error(error);
  }
marsh boltBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)