Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8158 bug UI not using presign for uploading objects #8365

Merged
Prev Previous commit
Next Next commit
minor changes
ItamarYuran committed Dec 10, 2024
commit 2b3ec1fe3ef954a0e62622353803872a5ce821a8
2 changes: 1 addition & 1 deletion webui/src/lib/api/index.js
Original file line number Diff line number Diff line change
@@ -770,7 +770,7 @@ class Objects {
const uploadUrl = `${API_ENDPOINT}/repositories/${encodeURIComponent(repoId)}/branches/${encodeURIComponent(branchId)}/objects?` + query;
const {status, body, rawHeaders} = await uploadWithProgress(uploadUrl, fileObject, 'POST', onProgressFn)
if (status !== 201) {
const contentType = rawHeaders ? parseRawHeaders(rawHeaders)['content-type'] : undefined;
const contentType = rawHeaders ? parseRawHeaders(rawHeaders)['content-type'] : undefined;
if (contentType === "application/json" && body) {
const responseData = JSON.parse(body)
throw new Error(responseData.message)
46 changes: 23 additions & 23 deletions webui/src/pages/repositories/repository/objects.jsx
Original file line number Diff line number Diff line change
@@ -236,35 +236,35 @@
// fallback to ETag
if (parsedHeaders['etag']) {
// drop any quote and space
return parsedHeaders['etag'].replace(/"/g, '');
return parsedHeaders['etag'].replace(/[" ]+/g, "");
}
return null;
}

const uploadFile = async (config, repo, reference, path, file, onProgress) => {
const fpath = destinationPath(path, file);
if (config.pre_sign_support_ui) {
let additionalHeaders;
if (config.blockstore_type === "azure") {
additionalHeaders = { "x-ms-blob-type": "BlockBlob" }
const fpath = destinationPath(path, file);
if (config.pre_sign_support_ui) {
let additionalHeaders;
if (config.blockstore_type === "azure") {
additionalHeaders = { "x-ms-blob-type": "BlockBlob" }
}
const getResp = await staging.get(repo.id, reference.id, fpath, config.pre_sign_support_ui);
try {
const uploadResponse = await uploadWithProgress(getResp.presigned_url, file, 'PUT', onProgress, additionalHeaders);
const parsedHeaders = parseRawHeaders(uploadResponse.rawHeaders);
const checksum = extractChecksumFromResponse(parsedHeaders);
await staging.link(repo.id, reference.id, fpath, getResp, checksum, file.size, file.type);
} catch(error) {
if (error.status >= 400) {
throw new Error(`Error uploading file: HTTP ${error.status}`);

Check failure on line 259 in webui/src/pages/repositories/repository/objects.jsx

GitHub Actions / Analyze

Mixed spaces and tabs

Check failure on line 259 in webui/src/pages/repositories/repository/objects.jsx

GitHub Actions / Test React App

Mixed spaces and tabs

Check failure on line 259 in webui/src/pages/repositories/repository/objects.jsx

GitHub Actions / Run Linters and Checkers

Mixed spaces and tabs

Check failure on line 259 in webui/src/pages/repositories/repository/objects.jsx

GitHub Actions / Generate code from latest lakeFS app

Mixed spaces and tabs
}
if (error.status === 0) {
throw new Error(`CORS settings error. Check documentation for more info.`);
}
const getResp = await staging.get(repo.id, reference.id, fpath, config.pre_sign_support_ui);
try {
const uploadResponse = await uploadWithProgress(getResp.presigned_url, file, 'PUT', onProgress, additionalHeaders);
const parsedHeaders = parseRawHeaders(uploadResponse.rawHeaders);
const checksum = extractChecksumFromResponse(parsedHeaders);
await staging.link(repo.id, reference.id, fpath, getResp, checksum, file.size, file.type);
} catch(error) {
if (error.status >= 400) {
throw new Error(`Error uploading file: HTTP ${error.status}`);
}
if (error.status === 0) {
throw new Error(`CORS settings error. Check documentation for more info.`);
}
throw error;
}
} else {
await objects.upload(repo.id, reference.id, fpath, file, onProgress);
throw error;
}
} else {
await objects.upload(repo.id, reference.id, fpath, file, onProgress);
}
};