unlayer / angular-email-editor

Drag-n-Drop Email Editor Component for Angular
https://unlayer.com
MIT License
203 stars 166 forks source link

Is there any way to change uploadMaxSize value? #61

Open aslubsky opened 3 years ago

aslubsky commented 3 years ago

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 commented 4 months ago

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

aslubsky commented 4 months ago

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

})

shankar5147 commented 4 months ago

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; } });