import { uploadFile } from "../../src/handler";
import { APIGatewayRequest } from "../eventGenerator";
import FormData from "form-data";
import fs from "fs";
export const uploadfile = () => {
it("Upload File", async () => {
const filePath = fs.createReadStream("../image/hulk.PNG");
const formData = new FormData();
formData.append("file", filePath);
formData.开发者_JAVA百科append("Title", "Jesting");
formData.append("Description", "JestingJest");
formData.append("Editor", "Jester");
console.log(formData);
const event = APIGatewayRequest({
body: formData,
method: "",
path: "",
queryStringObject: "",
pathParametersObject: "",
stageVariables: null,
});
const test = await uploadFile(event);
expect(test.statusCode).toBe(201);
}, 50000);
};
//////////////////////////////////////////////////////////////////////
...const request: APIGatewayProxyEvent = {
body: body ? JSON.stringify(body) : null,
headers: {
"for-coop-id": "test",
"content-type": "multipart/form-data",
// "Access-Control-Allow-Origin": "*",
},...
I did change content-type from all-caps it did not change a thing. I tried putting boundaries and removing content-type. Hope you could help.
精彩评论