async upload(context, { filename, content, showProgress = true, showSuccess = true, showError = true, num, count }) {
				const target = filename.split('/')[1]
				const cancelSource = BaseConnector.getCancelSource();
				const notification = (showProgress ? makeFileTransferNotification('upload', filename, cancelSource, num, count) : null);
				try {
					// Check if config.g needs to be backed up
					if (filename === Path.configFile) {
						try {
							await connector.move({ from: Path.configFile, to: Path.configBackupFile, force: true, silent: true });
						} catch (e) {
							console.warn(e);
							log('error', i18n.t('notification.upload.error', [Path.extractFileName(filename)]), e.message, hostname);
							return;
						}
					}

					// Perform upload
					const startTime = new Date();
					const response = await connector.upload({ filename, content, cancelSource, onProgress: (notification ? notification.onProgress : (e) => {	document.getElementById("fileProgress") ? document.getElementById('fileProgress').style.width = ((e.loaded / e.total) * 100).toFixed(1) + '%' : null})
				});

				// Show success message

				if (showSuccess && num === count && target != "gcodes") {
					if (count) {
						log('success', i18n.t('notification.upload.successMulti', [count]), undefined, hostname);
					} else {
						const secondsPassed = Math.round((new Date() - startTime) / 1000);
						log('success', i18n.t('notification.upload.success', [Path.extractFileName(filename), displayTime(secondsPassed)]), undefined, hostname);
					}
				} /*else {
					if (content.size > 2*1024*1024 && content.size <= 4*1024*1024) {
						document.getElementById("uploadDiv").style.display = "none"
					}
				}*/

				// Return the response
				if (showProgress) {
					notification.hide();
				}
				return response;
			} catch (e) {
				// Show and report error message
				if (showProgress) {
					notification.hide();
				}
				if (showError && !(e instanceof OperationCancelledError)) {
					console.warn(e);
					log('error', i18n.t('notification.upload.error', [Path.extractFileName(filename)]), e.message, hostname);
				}
				throw e;
			}
		}
// Upload a file and show progress
Upload a file and show progress
Upload a file and show progress
async upload(context, { filename, content, showProgress = true, showSuccess = true, showError = true, num, count }) {
				const target = filename.split('/')[1]
				const cancelSource = BaseConnector.getCancelSource();
				const notification = (showProgress ? makeFileTransferNotification('upload', filename, cancelSource, num, count) : null);
				try {
					if (filename === Path.configFile) {
						try {
							await connector.move({ from: Path.configFile, to: Path.configBackupFile, force: true, silent: true });
						} catch (e) {
							console.warn(e);
							log('error', i18n.t('notification.upload.error', [Path.extractFileName(filename)]), e.message, hostname);
							return;
						}
					}
					const startTime = new Date();
					const response = await connector.upload({ filename, content, cancelSource, onProgress: (notification ? notification.onProgress : (e) => {	document.getElementById("fileProgress") ? document.getElementById('fileProgress').style.width = ((e.loaded / e.total) * 100).toFixed(1) + '%' : null})
				});
				if (showSuccess && num === count && target != "gcodes") {
					if (count) {
						log('success', i18n.t('notification.upload.successMulti', [count]), undefined, hostname);
					} else {
						const secondsPassed = Math.round((new Date() - startTime) / 1000);
						log('success', i18n.t('notification.upload.success', [Path.extractFileName(filename), displayTime(secondsPassed)]), undefined, hostname);
					}
				} 
				if (showProgress) {
					notification.hide();
				}
				return response;
			} catch (e) {
				if (showProgress) {
					notification.hide();
				}
				if (showError && !(e instanceof OperationCancelledError)) {
					console.warn(e);
					log('error', i18n.t('notification.upload.error', [Path.extractFileName(filename)]), e.message, hostname);
				}
				throw e;
			}
		}
async upload ( context , { filename , content , showProgress = true , showSuccess = true , showError = true , num , count } ) { const target = filename . split ( '/' ) [ 1 ] const cancelSource = BaseConnector . getCancelSource ( ) ; const notification = ( showProgress ? makeFileTransferNotification ( 'upload' , filename , cancelSource , num , count ) : null ) ; try { if ( filename === Path . configFile ) { try { await connector . move ( { from : Path . configFile , to : Path . configBackupFile , force : true , silent : true } ) ; } catch ( e ) { console . warn ( e ) ; log ( 'error' , i18n . t ( 'notification.upload.error' , [ Path . extractFileName ( filename ) ] ) , e . message , hostname ) ; return ; } } const startTime = new Date ( ) ; const response = await connector . upload ( { filename , content , cancelSource , onProgress : ( notification ? notification . onProgress : ( e ) => { document . getElementById ( "fileProgress" ) ? document . getElementById ( 'fileProgress' ) . style . width = ( ( e . loaded / e . total ) * 100 ) . toFixed ( 1 ) + '%' : null } ) } ) ; if ( showSuccess && num === count && target != "gcodes" ) { if ( count ) { log ( 'success' , i18n . t ( 'notification.upload.successMulti' , [ count ] ) , undefined , hostname ) ; } else { const secondsPassed = Math . round ( ( new Date ( ) - startTime ) / 1000 ) ; log ( 'success' , i18n . t ( 'notification.upload.success' , [ Path . extractFileName ( filename ) , displayTime ( secondsPassed ) ] ) , undefined , hostname ) ; } } if ( showProgress ) { notification . hide ( ) ; } return response ; } catch ( e ) { if ( showProgress ) { notification . hide ( ) ; } if ( showError && ! ( e instanceof OperationCancelledError ) ) { console . warn ( e ) ; log ( 'error' , i18n . t ( 'notification.upload.error' , [ Path . extractFileName ( filename ) ] ) , e . message , hostname ) ; } throw e ; } }
Upload a file and show progress
Upload a file and show progress
// Check if config.g needs to be backed up // Perform upload // Show success message /*else {
					if (content.size > 2*1024*1024 && content.size <= 4*1024*1024) {
						document.getElementById("uploadDiv").style.display = "none"
					}
				}*/ // Return the response // Show and report error message