Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 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 @@ def display_major_project(user_dict=None):
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,17 @@ def submit_major_project(user_dict=None):
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}", ExtraArgs={
'ExpectedBucketOwner': app.config['S3_BUCKET_ID']
})

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