Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion conditional/blueprints/major_project_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
return render_template(
"major_project_submission.html",
major_projects=major_projects,
bucket_name=bucket,
major_projects_len=len(major_projects),
username=user_dict["username"])

Expand Down Expand Up @@ -156,12 +157,15 @@
for file in os.listdir(temp_dir):
filepath = f"{temp_dir}/{file}"

s3.upload_file(filepath, 'major-project-media', f"{project.id}/{file}")
s3.upload_file(filepath, app.config['S3_BUCKET_ID'], f"{project.id}/{file}")

Check failure on line 160 in conditional/blueprints/major_project_submission.py

View check run for this annotation

CSH-Sonarqube-Community / SonarQube Code Analysis

conditional/blueprints/major_project_submission.py#L160

Add the 'ExpectedBucketOwner' to the 'ExtraArgs' parameter to verify S3 bucket ownership.

os.remove(filepath)

# Delete the temp directory once all the files have been stored in S3
os.rmdir(temp_dir)
else:
log.error("Could not create temp directory for uploading files")
return jsonify({"success": False}), 500


# Send the slack ping only after we know that the data was properly saved to the DB
Expand Down
4 changes: 2 additions & 2 deletions conditional/templates/major_project_submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ <h5 class="img-header"><strong>Images</strong></h5>
{% for f in p['files'] %}
<img
class="proj-img"
src="https://assets.csh.rit.edu/major-project-media/{{ f }}"
src="https://assets.csh.rit.edu/{{ bucket_name }}/{{ f }}"
alt="User submitted image for the project"/>
{% endfor %}
{% endif %}
Expand All @@ -342,4 +342,4 @@ <h5 class="img-header"><strong>Images</strong></h5>
{% endif %}
</div>

{% endblock %}
{% endblock %}
Loading