private XMLHttpRequest newXhr(String url, HttpMethod method, Operation operation, OnError error, OnLoad onLoad) { XMLHttpRequest xhr = new XMLHttpRequest(); // The order of the XHR methods is important! Do not rearrange the code unless you know what you're doing! xhr.onload = event -> onLoad.onLoad(xhr); xhr.addEventListener("error", //NON-NLS event -> handleErrorCodes(url, (int) xhr.status, operation, error), false); xhr.open(method.name(), url, true); xhr.setRequestHeader(X_MANAGEMENT_CLIENT_NAME.header(), HEADER_MANAGEMENT_CLIENT_VALUE); String bearerToken = getBearerToken(); if (bearerToken != null) { xhr.setRequestHeader("Authorization", "Bearer " + bearerToken); } xhr.withCredentials = true; return xhr; }
public FileItem(File file, UploadOptions options) { this.file = file; this.options = options; initFileImage(); initFileTitle(); initFileSizeParagraph(); initFooter(); initProgress(); initThumbnail(); if (isExceedsMaxFile()) { invalidate("File is too large, maximum file size is " + formatSize(options.getMaxFileSize())); } request =new XMLHttpRequest(); init(this); }
public FileItem(File file, UploadOptions options) { this.file = file; this.options = options; initFileImage(); initFileTitle(); initFileSizeParagraph(); initFooter(); initProgress(); initThumbnail(); if (isExceedsMaxFile()) { invalidate("File is too large, maximum file size is " + formatSize(options.getMaxFileSize())); } request =new XMLHttpRequest(); init(this); }