Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Enhancement/projects file upload #62

Merged
merged 58 commits into from
Mar 12, 2024
Merged

Conversation

Gerwoud
Copy link
Contributor

@Gerwoud Gerwoud commented Mar 7, 2024

Create functionality of file uploading when using POST to projects

AronBuzogany and others added 28 commits March 6, 2024 13:42
400 when non zip is uploaded
@Gerwoud Gerwoud self-assigned this Mar 11, 2024
@Gerwoud Gerwoud marked this pull request as ready for review March 11, 2024 14:11
@Gerwoud Gerwoud requested review from AronBuzogany March 11, 2024 19:53

file.save(file_location + "/" + filename)
try:
with zipfile.ZipFile(file_location + "/" + filename) as upload_zip:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not solved eh


file_location = os.path.join(project_upload_directory)

if not os.path.exists(project_upload_directory):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use, exist_ok=True without the if :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


project_upload_directory = os.path.join(f"{UPLOAD_FOLDER}", f"{new_project.project_id}")

file_location = os.path.join(project_upload_directory)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.join with 1 argument has no effect, did you forget second argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgor 💀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# save the file that is given with the request

new_project = create_model_instance(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't handle the case where this fails

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that fails is me 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db.session.commit()
return jsonify({
"data": new_instance,
new_instance = create_model_instance(model, data, response_url_base, required_fields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use model_instance, status_code = create_model_instance instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f"{response_url_base}/",
str(getattr(new_instance, url_id_field)))}), 201
"url":
urljoin(response_url_base + "/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use f-string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# save the file that is given with the request

new_project, status_code = create_model_instance(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not doing anything about if it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vucis Vucis merged commit 33c4b59 into development Mar 12, 2024
2 checks passed
@Vucis Vucis deleted the enhancement/projects-file-upload branch March 12, 2024 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants