CEC-377 Create multi-file updates (#71)
* Replace Deploy Package with Deploy Manifest page Stub new controls for package files * Add Release notes and ECU FIles to Create Manifest * Add Release notes and ECU FIles to Create Manifest * Oops * Replace multi release notes with single url * Implement multiple file uploads and progress * Update snapshots * Unused import * Move file to end of form Update progress layout
This commit is contained in:
@@ -18,6 +18,13 @@ const manifestsAPI = {
|
||||
})
|
||||
.then(fetchRespHandler);
|
||||
},
|
||||
|
||||
createManifest: async (data, token) => fetch(`${API_ENDPOINT}/manifest`, {
|
||||
method: "POST",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, getAuthHeaderOptions(token)),
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then(fetchRespHandler),
|
||||
};
|
||||
|
||||
export default manifestsAPI;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const UPLOAD_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL || "https://gw-dev.fiskerdps.com/ota_update";
|
||||
const fileField = "file";
|
||||
|
||||
export const getCancelToken = () => {
|
||||
const token = axios.CancelToken;
|
||||
return token.source();
|
||||
}
|
||||
|
||||
export const uploadFile = (file, data, token, onProgress, cancelToken) => {
|
||||
export const uploadFile = (data, token, onProgress, cancelToken) => {
|
||||
const form = new FormData();
|
||||
let options = {
|
||||
method: "POST",
|
||||
@@ -17,19 +18,23 @@ export const uploadFile = (file, data, token, onProgress, cancelToken) => {
|
||||
},
|
||||
cancelToken,
|
||||
};
|
||||
|
||||
if (onProgress) {
|
||||
options = {
|
||||
...options,
|
||||
onUploadProgress: (event) => {
|
||||
onProgress(Math.min(99, Math.floor((event.loaded / event.total) * 100)));
|
||||
onProgress(event.loaded / event.total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let key in data) {
|
||||
form.append(key, data[key]);
|
||||
if (key !== fileField) form.append(key, data[key]);
|
||||
}
|
||||
form.append("file", file);
|
||||
return axios.post(`${UPLOAD_ENDPOINT}/update`, form, options)
|
||||
|
||||
form.append(fileField, data[fileField]);
|
||||
|
||||
return axios.post(`${UPLOAD_ENDPOINT}/manifestfile`, form, options)
|
||||
.then((response) => response.data)
|
||||
.catch((error) => {
|
||||
if (typeof error.response.data === "string") {
|
||||
|
||||
Reference in New Issue
Block a user