I have a widget where user will upload a pdf file and i've send that pdf to an external api . The api endpoint accepting .pdf file not binary . Odoo converted pdf or other file into binary. How can i get the raw pdf to send through the api ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
** This is tested in ODOO V15 **
if you are using FileReader() in JavaScript before sending the file,
the FileReader is appending the “data URI scheme” which makes it impossible for odoo to identify the file, as a result “application/octet-stream” is assigned to it when it's saved in ir_attatchement table,
the solution is to remove this prefix so that odoo can decode the base64 encoded file correctly and assign it the correct mimetype in ir_attatchement
handleFileChange(event) {
const file = event.target.files[0]; // Get the selected file
if (file) {
// If a file is selected, we need to read it (e.g., as base64 or binary)
const reader = new FileReader();
reader.onloadend = () => {
// Update the state using the setter function provided by useState
// the string below is removed so that odoo can recognize mimetype of pdf files
this.state.file = reader.result.replace(/^data:.+;base64,/, "");
};
reader.readAsDataURL(file); // Read the file as a data URL (base64 encoded)
} else {
this.state.file = null; // Clear the preview if no file is selected
}
}
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
3
أغسطس 25
|
2670 | ||
|
1
مايو 25
|
2668 | ||
|
1
أبريل 25
|
3670 | ||
|
1
أبريل 25
|
4520 | ||
|
1
أبريل 25
|
1986 |