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
4 changes: 2 additions & 2 deletions contentcuration/contentcuration/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def write_file_to_storage(fobj, check_valid = False, name=None):
name = name or fobj._name or ""
filename, ext = os.path.splitext(name)
hashed_filename = checksum.hexdigest()
full_filename = "{}{}".format(hashed_filename, ext)
full_filename = "{}{}".format(hashed_filename, ext.lower())
fobj.seek(0)

if check_valid and hashed_filename != filename:
Expand All @@ -54,7 +54,7 @@ def write_raw_content_to_storage(contents, ext=None):
checksum = hashlib.md5()
checksum.update(contents)
filename = checksum.hexdigest()
full_filename = "{}.{}".format(filename, ext)
full_filename = "{}.{}".format(filename, ext.lower())

# Get location of file
file_path = models.generate_file_on_disk_name(filename, full_filename)
Expand Down
6 changes: 3 additions & 3 deletions contentcuration/contentcuration/view/internal_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.views.decorators.csrf import csrf_exempt
from django.template.loader import render_to_string
from contentcuration.api import write_file_to_storage
from contentcuration.models import Exercise, AssessmentItem, Channel, License, FileFormat, File, FormatPreset, ContentKind, ContentNode, ContentTag, Invitation, Language, generate_file_on_disk_name
from contentcuration.models import Exercise, AssessmentItem, Channel, License, FileFormat, File, FormatPreset, ContentKind, ContentNode, ContentTag, Invitation, Language, generate_file_on_disk_name, generate_storage_url
from contentcuration import ricecooker_versions as rc
from le_utils.constants import content_kinds
from django.db.models.functions import Concat
Expand Down Expand Up @@ -305,7 +305,7 @@ def map_files_to_node(node, data):
if file_data.get('language'):
language = Language.objects.get(pk=file_data['language'])

file_path=generate_file_on_disk_name(file_hash[0], file_data['filename'])
file_path=generate_storage_url(file_data['filename'])
if not os.path.isfile(file_path):
raise IOError('{} not found'.format(file_path))

Expand All @@ -326,7 +326,7 @@ def map_files_to_assessment_item(question, data):
""" Generate files that reference the content node's assessment items """
for file_data in data:
file_hash = file_data['filename'].split(".")
file_path = generate_file_on_disk_name(file_hash[0], file_data['filename'])
file_path = generate_storage_url(file_data['filename'])
if not os.path.isfile(file_path):
raise IOError('{} not found'.format(file_path))

Expand Down