-
Notifications
You must be signed in to change notification settings - Fork 314
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
feat(rest.packages.provider): add endpoint for .dp
upload
#4894
Merged
MMaiero
merged 24 commits into
eclipse-kura:develop
from
mattdibi:experimental/dp_upload_v2
Oct 30, 2023
Merged
feat(rest.packages.provider): add endpoint for .dp
upload
#4894
MMaiero
merged 24 commits into
eclipse-kura:develop
from
mattdibi:experimental/dp_upload_v2
Oct 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 tasks
WARNING: not completely working
P.s. I have no idea what I'm doing
Still WIP
mattdibi
force-pushed
the
experimental/dp_upload_v2
branch
from
October 27, 2023 10:02
c4af0be
to
dc857ad
Compare
I've tested this with the browser and the new session REST APIs using the following snippet, it seems to work fine. <!doctype html>
<html>
<body>
<input id="username" />
<input id="password" />
<form id="upload-form">
<input type="file" id="dp-upload" name="file"/>
</form>
<button id="upload-button">Login and Upload</button>
<div id="output"></div>
<script>
var username = document.getElementById('username');
var password = document.getElementById('password');
var uploadForm = document.getElementById("upload-form");
var uploadButton = document.getElementById("upload-button");
var output = document.getElementById('output');
function print(msg) {
const p = document.createElement('p');
p.textContent = msg
output.append(p)
}
async function doLogin() {
await fetch('/services/session/v1/login/password', {
method: 'POST',
headers: {
"Content-Type": "application/json",
Accept: "application/json"
},
body: JSON.stringify({
username: username.value,
password: password.value
})
});
const response = await fetch('/services/session/v1/xsrfToken', {
method: 'GET',
headers: {
Accept: "application/json"
}
});
return (await response.json()).xsrfToken;
}
async function doUpload(xsrfToken) {
const formData = new FormData(uploadForm);
const response = await fetch("/services/deploy/v2/_upload", {
method: 'POST',
headers: {
'X-XSRF-Token': xsrfToken
},
body: formData,
})
return response.status
}
uploadButton.addEventListener('click', async () => {
print('uploading...')
const xsrfToken = await doLogin();
const status = await doUpload(xsrfToken);
print('uploading... done. got status ' + status)
});
</script>
</body>
</html> |
nicolatimeus
approved these changes
Oct 30, 2023
3 tasks
This was referenced Nov 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR follows #4868 and adds the endpoint for
.dp
file upload. It leveragesmultipart/form-data
under the hood.Can be tested using:
and then:
Roadmap:
deploy/v2
in its current form (feat(rest.packages.provider): adddeploy/v2
Rest API #4868)multipart/form-data
(feat(rest.packages.provider): add endpoint for.dp
upload #4894)install
endpoint