unstable_createMemoryUploadHandler

unstable_createMemoryUploadHandler

此 API 已在 React Router v7 中移除。请参阅 the React Router guide to file uploads 了解推荐的替代 API。

示例:

¥Example:

export const action = async ({
  request,
}: ActionFunctionArgs) => {
  const uploadHandler = unstable_createMemoryUploadHandler({
    maxPartSize: 500_000,
  });
  const formData = await unstable_parseMultipartFormData(
    request,
    uploadHandler
  );

  const file = formData.get("avatar");

  // file is a "File" (https://mdn.io/File) polyfilled for node
  // ... etc
};

选项:唯一支持的选项是 maxPartSizefilter,它们的工作方式与上面的 unstable_createFileUploadHandler 相同。不建议将此 API 用于任何大规模应用,但它是一个方便的实用程序,适用于简单的用例,并可作为其他处理程序的后备。

¥Options: The only options supported are maxPartSize and filter which work the same as in unstable_createFileUploadHandler above. This API is not recommended for anything at scale but is a convenient utility for simple use cases and as a fallback for another handler.

Remix v2.17 中文网 - 粤ICP备13048890号