<commit_before>""" File Uploads backends. """
from __future__ import absolute_import

import abc
import mimetypes

import six

from django.conf import settings

from ..exceptions import FileUploadInternalError, FileUploadRequestError


class Settings(object):
    """Store settings related to file upload

    The following settings are used:

        FILE_UPLOAD_STORAGE_BUCKET_NAME (str, required): name of the bucket
        (AWS or local file directory) to which content will be uploaded.

        FILE_STORAGE_STORAGE_PREFIX (str, defaults to
        DEFAULT_FILE_UPLOAD_STORAGE_PREFIX): this will be used to prefix all
        stored file names. The specified file prefix for the storage must be
        publicly viewable or all uploaded files will not be seen.
    """
    DEFAULT_FILE_UPLOAD_STORAGE_PREFIX = "submissions_attachments"  # pylint: disable=invalid-name
    FILE_EXTENSIONS_BY_TYPE = {
        'image/gif': '.gif',
        'image/jpeg': '.jpg',
        'image/pjpeg': '.jpg',
        'image/png': '.png',
        'application/pdf': '.pdf'
    }

    @classmethod
    def get_bucket_name(cls):
        bucket_name = getattr(settings, "FILE_UPLOAD_STORAGE_BUCKET_NAME", None)
        if not bucket_name:
            raise FileUploadInternalError("No bucket name configured for FileUpload Service.")
        return bucket_name

    @classmethod
    def get_prefix(cls):
        """Return the prefix for stored files.
<commit_msg>Support .doc and .docx file extensions for file attachment download<commit_after>""" File Uploads backends. """
from __future__ import absolute_import

import abc
import mimetypes

import six

from django.conf import settings

from ..exceptions import FileUploadInternalError, FileUploadRequestError


class Settings(object):
    """Store settings related to file upload

    The following settings are used:

        FILE_UPLOAD_STORAGE_BUCKET_NAME (str, required): name of the bucket
        (AWS or local file directory) to which content will be uploaded.

        FILE_STORAGE_STORAGE_PREFIX (str, defaults to
        DEFAULT_FILE_UPLOAD_STORAGE_PREFIX): this will be used to prefix all
        stored file names. The specified file prefix for the storage must be
        publicly viewable or all uploaded files will not be seen.
    """
    DEFAULT_FILE_UPLOAD_STORAGE_PREFIX = "submissions_attachments"  # pylint: disable=invalid-name
    FILE_EXTENSIONS_BY_TYPE = {
        'image/gif': '.gif',
        'image/jpeg': '.jpg',
        'image/pjpeg': '.jpg',
        'image/png': '.png',
        'application/pdf': '.pdf',
        'application/msword': '.doc',
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '.docx'
    }

    @classmethod
    def get_bucket_name(cls):
        bucket_name = getattr(settings, "FILE_UPLOAD_STORAGE_BUCKET_NAME", None)
        if not bucket_name:
            raise FileUploadInternalError("No bucket name configured for FileUpload Service.")
        return bucket_name

    @classmethod
    def get_prefix(cls):
        """Return the prefix for stored files.

{'fraction_non_alphanumeric': 0.0792722547108512, 'fraction_numerical': 0.0, 'mean_word_length': 3.2293956043956045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927872', 'n_tokens_mistral': 875, 'n_tokens_neox': 873, 'n_words': 277}