angular-email-editor icon indicating copy to clipboard operation
angular-email-editor copied to clipboard

Is there any way to change uploadMaxSize value?

Open aslubsky opened this issue 4 years ago • 3 comments

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?

aslubsky avatar May 28 '21 07:05 aslubsky

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

shankar5147 avatar Jun 24 '24 12:06 shankar5147

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

})

aslubsky avatar Jun 24 '24 12:06 aslubsky

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

shankar5147 avatar Jun 24 '24 13:06 shankar5147