Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to change uploadMaxSize value? #61

Open
aslubsky opened this issue May 28, 2021 · 3 comments
Open

Is there any way to change uploadMaxSize value? #61

aslubsky opened this issue May 28, 2021 · 3 comments

Comments

@aslubsky
Copy link

Hi

Thanks for awesome editor. Is there any way to change uploadMaxSize value? Default it's 1e6 bytes. Is it possible to change this in free version?

@shankar5147
Copy link

shankar5147 commented Jun 24, 2024

@aslubsky have you found any solution, I am facing the same issue.

@aslubsky
Copy link
Author

Yes, we use custom callback for handling image upload process.
editor.registerCallback('image', () => {

})

@shankar5147
Copy link

Thanks for reply @aslubsky, can you provide any example where we can change the upload. i am already wrote this callback event but same issue.

this.emailEditor.editor.registerCallback('image', (file, done) => {
console.log(file);
let fileName = file.attachments[0].name;
let exten = fileName.split('.').length;
let extenstions = ['jpg', 'jpeg', 'png'];
let fileValidate = extenstions.includes(fileName.split('.')[exten - 1]);
if (file.attachments[0].size > image25MB) { // 2.5 MB
this.sharedService.showMessages('error', 'Image Upload', 'File size should not be greater than 2.5MB');
return;
} else if (fileValidate) {
let formData = new FormData();
formData.append('filesToUploads', file.attachments[0]);
formData.append('agencyId', sessionStorage.getItem('agentId'));
formData.append('fileType', (this.requestFrom == 'emailTab') ? 'CONVERSATION' : (this.requestFrom == 'composeEmailTab') ? 'EMAILTEMPLATE' : (this.requestFrom == 'sequence') ? 'SEQUENCES' : 'EMAILTEMPLATE');
console.log(file.attachments[0]);
fetch(${environment.host}file/upload-file, {
method: 'POST',
headers: {
'Accept': 'application/json'
},
body: formData
}).then((response: any) => {
// Make sure the response was valid
console.log(response);
if (response.status == 200) {
return response
} else {
this.sharedService.showMessages('error', 'Image Upload', response.statusText);
var error: any = new Error(response.statusText)
error.response = response
throw error
}
}).then(response => {
return response.json()
}).then(data => {
// Pass the URL back to Unlayer to mark this upload as completed
console.log(data);
done({ progress: 100, url: data["data"][0]["path"] })
})
} else {
this.sharedService.showMessages('error', 'Image Upload', 'Uploaded file type is not accepted');
return;
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants