Skip to content

Commit 92b29e7

Browse files
committed
make it use the right bucket name (#518)
* make it use the right bucket name * expected owner arg * making sonarqube happy
1 parent bf0ca6d commit 92b29e7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

conditional/blueprints/major_project_submission.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def display_major_project(user_dict=None):
6565
return render_template(
6666
"major_project_submission.html",
6767
major_projects=major_projects,
68+
bucket_name=bucket,
6869
major_projects_len=len(major_projects),
6970
username=user_dict["username"])
7071

@@ -156,12 +157,17 @@ def submit_major_project(user_dict=None):
156157
for file in os.listdir(temp_dir):
157158
filepath = f"{temp_dir}/{file}"
158159

159-
s3.upload_file(filepath, 'major-project-media', f"{project.id}/{file}")
160+
s3.upload_file(filepath, app.config['S3_BUCKET_ID'], f"{project.id}/{file}", ExtraArgs={
161+
'ExpectedBucketOwner': app.config['S3_BUCKET_ID']
162+
})
160163

161164
os.remove(filepath)
162165

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

166172

167173
# Send the slack ping only after we know that the data was properly saved to the DB

conditional/templates/major_project_submission.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ <h5 class="img-header"><strong>Images</strong></h5>
326326
{% for f in p['files'] %}
327327
<img
328328
class="proj-img"
329-
src="https://assets.csh.rit.edu/major-project-media/{{ f }}"
329+
src="https://assets.csh.rit.edu/{{ bucket_name }}/{{ f }}"
330330
alt="User submitted image for the project"/>
331331
{% endfor %}
332332
{% endif %}
@@ -342,4 +342,4 @@ <h5 class="img-header"><strong>Images</strong></h5>
342342
{% endif %}
343343
</div>
344344

345-
{% endblock %}
345+
{% endblock %}

0 commit comments

Comments
 (0)