{"title":"File storage API","version":"3.2","locale":"ko","docname":"ref/files/storage","url":"/ko/3.2/ref/files/storage/","canonical":"https://djangodocs.dev/ko/3.2/ref/files/storage/","summary":"Getting the current storage class Link to this heading # Django provides two convenient ways to access the current storage class: class DefaultStorage Link to this…","html":"<span id=\"file-storage-api\"></span><h1>File storage API<a class=\"heading-anchor\" href=\"#module-django.core.files.storage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"getting-the-current-storage-class\">\n<h2>Getting the current storage class<a class=\"heading-anchor\" href=\"#getting-the-current-storage-class\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django provides two convenient ways to access the current storage class:</p>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.DefaultStorage\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">DefaultStorage</span></span><a class=\"heading-anchor\" href=\"#django.core.files.storage.DefaultStorage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p><a class=\"reference internal\" href=\"#django.core.files.storage.DefaultStorage\" title=\"django.core.files.storage.DefaultStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">DefaultStorage</span></code></a> provides\nlazy access to the current default storage system as defined by\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEFAULT_FILE_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEFAULT_FILE_STORAGE</span></code></a>. <a class=\"reference internal\" href=\"#django.core.files.storage.DefaultStorage\" title=\"django.core.files.storage.DefaultStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">DefaultStorage</span></code></a> uses\n<a class=\"reference internal\" href=\"#django.core.files.storage.get_storage_class\" title=\"django.core.files.storage.get_storage_class\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">get_storage_class()</span></code></a> internally.</p>\n</dd></dl>\n\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.get_storage_class\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_storage_class</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">import_path</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.get_storage_class\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a class or module which implements the storage API.</p>\n<p>When called without the <code class=\"docutils literal notranslate\"><span class=\"pre\">import_path</span></code> parameter <code class=\"docutils literal notranslate\"><span class=\"pre\">get_storage_class</span></code>\nwill return the current default storage system as defined by\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEFAULT_FILE_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEFAULT_FILE_STORAGE</span></code></a>. If <code class=\"docutils literal notranslate\"><span class=\"pre\">import_path</span></code> is provided,\n<code class=\"docutils literal notranslate\"><span class=\"pre\">get_storage_class</span></code> will attempt to import the class or module from the\ngiven path and will return it if successful. An exception will be\nraised if the import is unsuccessful.</p>\n</dd></dl>\n\n</section>\n<section id=\"the-filesystemstorage-class\">\n<h2>The <code class=\"docutils literal notranslate\"><span class=\"pre\">FileSystemStorage</span></code> class<a class=\"heading-anchor\" href=\"#the-filesystemstorage-class\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.FileSystemStorage\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">FileSystemStorage</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">location</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">base_url</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">file_permissions_mode</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">directory_permissions_mode</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The <a class=\"reference internal\" href=\"#django.core.files.storage.FileSystemStorage\" title=\"django.core.files.storage.FileSystemStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">FileSystemStorage</span></code></a> class implements\nbasic file storage on a local filesystem. It inherits from\n<a class=\"reference internal\" href=\"#django.core.files.storage.Storage\" title=\"django.core.files.storage.Storage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">Storage</span></code></a> and provides implementations\nfor all the public methods thereof.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.FileSystemStorage.location\">\n<span class=\"sig-name descname\"><span class=\"pre\">location</span></span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.location\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Absolute path to the directory that will hold the files.\nDefaults to the value of your <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_ROOT</span></code></a> setting.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.FileSystemStorage.base_url\">\n<span class=\"sig-name descname\"><span class=\"pre\">base_url</span></span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.base_url\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>URL that serves the files stored at this location.\nDefaults to the value of your <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_URL</span></code></a> setting.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.FileSystemStorage.file_permissions_mode\">\n<span class=\"sig-name descname\"><span class=\"pre\">file_permissions_mode</span></span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.file_permissions_mode\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The file system permissions that the file will receive when it is\nsaved. Defaults to <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-FILE_UPLOAD_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">FILE_UPLOAD_PERMISSIONS</span></code></a>.</p>\n</dd></dl>\n\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.FileSystemStorage.directory_permissions_mode\">\n<span class=\"sig-name descname\"><span class=\"pre\">directory_permissions_mode</span></span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.directory_permissions_mode\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The file system permissions that the directory will receive when it is\nsaved. Defaults to <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-FILE_UPLOAD_DIRECTORY_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">FILE_UPLOAD_DIRECTORY_PERMISSIONS</span></code></a>.</p>\n</dd></dl>\n\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">참고</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">FileSystemStorage.delete()</span></code> method will not raise\nan exception if the given file name does not exist.</p>\n</aside>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.FileSystemStorage.get_created_time\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_created_time</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.get_created_time\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(Python v3.14에서)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">datetime</span></code></a> of the system’s ctime, i.e.\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/os.path.html#os.path.getctime\" title=\"(Python v3.14에서)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">os.path.getctime()</span></code></a>. On some systems (like Unix), this is the\ntime of the last metadata change, and on others (like Windows), it’s\nthe creation time of the file.</p>\n</dd></dl>\n\n</dd></dl>\n\n<aside class=\"version-note version-changed\" data-version=\"3.1\">\n<p class=\"version-note-title\">Changed in Django 3.1</p><p>Support for <a class=\"reference external\" href=\"https://docs.python.org/3/library/pathlib.html#pathlib.Path\" title=\"(Python v3.14에서)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">pathlib.Path</span></code></a> was added to the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">FileSystemStorage.save()</span></code> method.</p>\n</aside>\n</section>\n<section id=\"the-storage-class\">\n<h2>The <code class=\"docutils literal notranslate\"><span class=\"pre\">Storage</span></code> class<a class=\"heading-anchor\" href=\"#the-storage-class\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">Storage</span></span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The <a class=\"reference internal\" href=\"#django.core.files.storage.Storage\" title=\"django.core.files.storage.Storage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">Storage</span></code></a> class provides a\nstandardized API for storing files, along with a set of default\nbehaviors that all other storage systems can inherit or override\nas necessary.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">참고</p>\n<p>When methods return naive <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code> objects, the effective timezone\nused will be the current value of <code class=\"docutils literal notranslate\"><span class=\"pre\">os.environ['TZ']</span></code>; note that this\nis usually set from Django’s <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-TIME_ZONE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">TIME_ZONE</span></code></a>.</p>\n</aside>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.delete\">\n<span class=\"sig-name descname\"><span class=\"pre\">delete</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.delete\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Deletes the file referenced by <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code>. If deletion is not supported\non the target storage system this will raise <code class=\"docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code>\ninstead.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.exists\">\n<span class=\"sig-name descname\"><span class=\"pre\">exists</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.exists\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> if a file referenced by the given name already exists\nin the storage system, or <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code> if the name is available for a new\nfile.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.get_accessed_time\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_accessed_time</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_accessed_time\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(Python v3.14에서)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">datetime</span></code></a> of the last accessed time of the\nfile. For storage systems unable to return the last accessed time this\nwill raise <a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#NotImplementedError\" title=\"(Python v3.14에서)\"><code class=\"xref py py-exc docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code></a>.</p>\n<p>If <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">USE_TZ</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>, returns an aware <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code>,\notherwise returns a naive <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code> in the local timezone.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.get_alternative_name\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_alternative_name</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">file_root</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">file_ext</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_alternative_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns an alternative filename based on the <code class=\"docutils literal notranslate\"><span class=\"pre\">file_root</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">file_ext</span></code> parameters, an underscore plus a random 7 character\nalphanumeric string is appended to the filename before the extension.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.get_available_name\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_available_name</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">max_length</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_available_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a filename based on the <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code> parameter that’s free and\navailable for new content to be written to on the target storage\nsystem.</p>\n<p>The length of the filename will not exceed <code class=\"docutils literal notranslate\"><span class=\"pre\">max_length</span></code>, if provided.\nIf a free unique filename cannot be found, a\n<a class=\"reference internal\" href=\"/ko/3.2/ref/exceptions/#django.core.exceptions.SuspiciousOperation\" title=\"django.core.exceptions.SuspiciousOperation\"><code class=\"xref py py-exc docutils literal notranslate\"><span class=\"pre\">SuspiciousFileOperation</span></code></a> exception will be raised.</p>\n<p>If a file with <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code> already exists, <a class=\"reference internal\" href=\"/ko/3.2/howto/custom-file-storage/#django.core.files.storage.get_alternative_name\" title=\"django.core.files.storage.get_alternative_name\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">get_alternative_name()</span></code></a> is\ncalled to obtain an alternative name.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.get_created_time\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_created_time</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_created_time\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(Python v3.14에서)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">datetime</span></code></a> of the creation time of the file.\nFor storage systems unable to return the creation time this will raise\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#NotImplementedError\" title=\"(Python v3.14에서)\"><code class=\"xref py py-exc docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code></a>.</p>\n<p>If <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">USE_TZ</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>, returns an aware <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code>,\notherwise returns a naive <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code> in the local timezone.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.get_modified_time\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_modified_time</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_modified_time\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(Python v3.14에서)\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">datetime</span></code></a> of the last modified time of the\nfile. For storage systems unable to return the last modified time this\nwill raise <a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#NotImplementedError\" title=\"(Python v3.14에서)\"><code class=\"xref py py-exc docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code></a>.</p>\n<p>If <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">USE_TZ</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>, returns an aware <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code>,\notherwise returns a naive <code class=\"docutils literal notranslate\"><span class=\"pre\">datetime</span></code> in the local timezone.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.get_valid_name\">\n<span class=\"sig-name descname\"><span class=\"pre\">get_valid_name</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_valid_name\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a filename based on the <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code> parameter that’s suitable\nfor use on the target storage system.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.generate_filename\">\n<span class=\"sig-name descname\"><span class=\"pre\">generate_filename</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">filename</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.generate_filename\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Validates the <code class=\"docutils literal notranslate\"><span class=\"pre\">filename</span></code> by calling <a class=\"reference internal\" href=\"/ko/3.2/howto/custom-file-storage/#django.core.files.storage.get_valid_name\" title=\"django.core.files.storage.get_valid_name\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">get_valid_name()</span></code></a> and\nreturns a filename to be passed to the <a class=\"reference internal\" href=\"#django.core.files.storage.Storage.save\" title=\"django.core.files.storage.Storage.save\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">save()</span></code></a> method.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">filename</span></code> argument may include a path as returned by\n<a class=\"reference internal\" href=\"/ko/3.2/ref/models/fields/#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">FileField.upload_to</span></code></a>.\nIn that case, the path won’t be passed to <a class=\"reference internal\" href=\"/ko/3.2/howto/custom-file-storage/#django.core.files.storage.get_valid_name\" title=\"django.core.files.storage.get_valid_name\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">get_valid_name()</span></code></a> but\nwill be prepended back to the resulting name.</p>\n<p>The default implementation uses <a class=\"reference external\" href=\"https://docs.python.org/3/library/os.path.html#module-os.path\" title=\"(Python v3.14에서)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">os.path</span></code></a> operations. Override\nthis method if that’s not appropriate for your storage.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.listdir\">\n<span class=\"sig-name descname\"><span class=\"pre\">listdir</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">path</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.listdir\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Lists the contents of the specified path, returning a 2-tuple of lists;\nthe first item being directories, the second item being files. For\nstorage systems that aren’t able to provide such a listing, this will\nraise a <code class=\"docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code> instead.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.open\">\n<span class=\"sig-name descname\"><span class=\"pre\">open</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">mode</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">'rb'</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.open\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Opens the file given by <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code>. Note that although the returned file\nis guaranteed to be a <code class=\"docutils literal notranslate\"><span class=\"pre\">File</span></code> object, it might actually be some\nsubclass. In the case of remote file storage this means that\nreading/writing could be quite slow, so be warned.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.path\">\n<span class=\"sig-name descname\"><span class=\"pre\">path</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.path\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>The local filesystem path where the file can be opened using Python’s\nstandard <code class=\"docutils literal notranslate\"><span class=\"pre\">open()</span></code>. For storage systems that aren’t accessible from\nthe local filesystem, this will raise <code class=\"docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code> instead.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.save\">\n<span class=\"sig-name descname\"><span class=\"pre\">save</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">content</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">max_length</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.save\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Saves a new file using the storage system, preferably with the name\nspecified. If there already exists a file with this name <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code>, the\nstorage system may modify the filename as necessary to get a unique\nname. The actual name of the stored file will be returned.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">max_length</span></code> argument is passed along to\n<a class=\"reference internal\" href=\"/ko/3.2/howto/custom-file-storage/#django.core.files.storage.get_available_name\" title=\"django.core.files.storage.get_available_name\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">get_available_name()</span></code></a>.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">content</span></code> argument must be an instance of\n<a class=\"reference internal\" href=\"/ko/3.2/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.core.files.File</span></code></a> or a file-like object that can be\nwrapped in <code class=\"docutils literal notranslate\"><span class=\"pre\">File</span></code>.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.size\">\n<span class=\"sig-name descname\"><span class=\"pre\">size</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.size\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the total size, in bytes, of the file referenced by <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code>.\nFor storage systems that aren’t able to return the file size this will\nraise <code class=\"docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code> instead.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.url\">\n<span class=\"sig-name descname\"><span class=\"pre\">url</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.url\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns the URL where the contents of the file referenced by <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code>\ncan be accessed. For storage systems that don’t support access by URL\nthis will raise <code class=\"docutils literal notranslate\"><span class=\"pre\">NotImplementedError</span></code> instead.</p>\n</dd></dl>\n\n</dd></dl>\n\n</section>","rootId":"module-django.core.files.storage","toc":[{"title":"Getting the current storage class","anchor":"getting-the-current-storage-class","children":[]},{"title":"The FileSystemStorage class","anchor":"the-filesystemstorage-class","children":[]},{"title":"The Storage class","anchor":"the-storage-class","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/ko/3.2/ref/"},{"docname":"ref/files/index","title":"File handling","url":"/ko/3.2/ref/files/"}],"prev":{"docname":"ref/files/file","title":"The File object","url":"/ko/3.2/ref/files/file/"},"next":{"docname":"ref/files/uploads","title":"Uploaded Files and Upload Handlers","url":"/ko/3.2/ref/files/uploads/"},"formats":{"html":"/ko/3.2/ref/files/storage/","markdown":"/ko/3.2/ref/files/storage.md","json":"/ko/3.2/ref/files/storage.json"},"source":"https://github.com/django/django/blob/stable/3.2.x/docs/ref/files/storage.txt","official":"https://docs.djangoproject.com/ko/3.2/ref/files/storage/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}