unstable_createMemoryUploadHandler
示例
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
};
选项:支持的唯一选项是maxPartSize
和filter
,它们的工作方式与上面的unstable_createFileUploadHandler
相同。此 API 不建议用于任何大规模场景,但对于简单的用例以及作为其他处理程序的回退非常方便。