88. الگوی Integration برای File → File
الگوی File → File از نظر مسیر Input/Output قابل استفاده است. برای تست Contract یک Endpoint واقعی یا آزمایشگاهی، میتوان Provider کمریسک زیر را ساخت:
Name:
EchoOrTransformFile
Type:
REST
Method:
POST
Request Content Type:
multipart/form-data
Input:
file File form-data
Response:
File
Endpoint تست:
- File را دریافت کند؛
- همان File یا نسخه Transformشده را برگرداند؛
- Header مناسب را تنظیم کند:
Content-Disposition: attachment; filename="output.bin"
Client:
global
.getFileFromUser({
accept: '*'
})
.then(file => {
return absoluteMethodHelper.runProvider(
PROVIDER_ID,
[
{
name: 'file',
value: file
}
]
);
})
.then(result => {
saveAs(
result.Content,
result.Content.name
);
});
این Test Case یکجا اثبات میکند:
File Picker
→ File Input
→ multipart/form-data
→ File Output
→ Download