unstable_createMemoryUploadHandler
示例:
¥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
};
选项:唯一支持的选项是 maxPartSize
和 filter
,它们的工作方式与上面的 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.