{"title":"File storage API","version":"1.10","locale":"pt-br","docname":"ref/files/storage","url":"/pt-br/1.10/ref/files/storage/","canonical":"https://djangodocs.dev/pt-br/1.10/ref/files/storage/","summary":"Django provides two convenient ways to access the current storage class. DefaultStorage provides lazy access to the current default storage system as…","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 para este cabeçalho</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 para este cabeçalho</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\">class</span> </em><span class=\"sig-name descname\">DefaultStorage</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.DefaultStorage\"><span class=\"visually-hidden\">Link para esta definição</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\">DefaultStorage</code></a> provides\nlazy access to the current default storage system as defined by\n<a class=\"reference internal\" href=\"/pt-br/1.10/ref/settings/#std-setting-DEFAULT_FILE_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">DEFAULT_FILE_STORAGE</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\">DefaultStorage</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\">get_storage_class()</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\">get_storage_class</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">import_path<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.get_storage_class\"><span class=\"visually-hidden\">Link para esta definição</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\">import_path</code> parameter <code class=\"docutils literal notranslate\">get_storage_class</code>\nwill return the current default storage system as defined by\n<a class=\"reference internal\" href=\"/pt-br/1.10/ref/settings/#std-setting-DEFAULT_FILE_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">DEFAULT_FILE_STORAGE</code></a>. If <code class=\"docutils literal notranslate\">import_path</code> is provided,\n<code class=\"docutils literal notranslate\">get_storage_class</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\">FileSystemStorage</code> class<a class=\"heading-anchor\" href=\"#the-filesystemstorage-class\"><span class=\"visually-hidden\">Link para este cabeçalho</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\">class</span> </em><span class=\"sig-name descname\">FileSystemStorage</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">location<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">base_url<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">file_permissions_mode<span class=\"o\">=</span><span class=\"default_value\">None</span></em>, <em class=\"sig-param\">directory_permissions_mode<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage\"><span class=\"visually-hidden\">Link para esta definição</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\">FileSystemStorage</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\">Storage</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\">location</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.location\"><span class=\"visually-hidden\">Link para esta definição</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=\"/pt-br/1.10/ref/settings/#std-setting-MEDIA_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_ROOT</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\">base_url</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.base_url\"><span class=\"visually-hidden\">Link para esta definição</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=\"/pt-br/1.10/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_URL</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\">file_permissions_mode</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.file_permissions_mode\"><span class=\"visually-hidden\">Link para esta definição</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=\"/pt-br/1.10/ref/settings/#std-setting-FILE_UPLOAD_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\">FILE_UPLOAD_PERMISSIONS</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\">directory_permissions_mode</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.FileSystemStorage.directory_permissions_mode\"><span class=\"visually-hidden\">Link para esta definição</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=\"/pt-br/1.10/ref/settings/#std-setting-FILE_UPLOAD_DIRECTORY_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\">FILE_UPLOAD_DIRECTORY_PERMISSIONS</code></a>.</p>\n</dd></dl>\n\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>The <code class=\"docutils literal notranslate\">FileSystemStorage.delete()</code> method will not raise\nan exception if the given file name does not exist.</p>\n</aside>\n</dd></dl>\n\n</section>\n<section id=\"the-storage-class\">\n<h2>The <code class=\"docutils literal notranslate\">Storage</code> class<a class=\"heading-anchor\" href=\"#the-storage-class\"><span class=\"visually-hidden\">Link para este cabeçalho</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\">class</span> </em><span class=\"sig-name descname\">Storage</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage\"><span class=\"visually-hidden\">Link para esta definição</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\">Storage</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\">Nota</p>\n<p>When methods return naive <code class=\"docutils literal notranslate\">datetime</code> objects, the effective timezone\nused will be the current value of <code class=\"docutils literal notranslate\">os.environ['TZ']</code>; note that this\nis usually set from Django’s <a class=\"reference internal\" href=\"/pt-br/1.10/ref/settings/#std-setting-TIME_ZONE\"><code class=\"xref std std-setting docutils literal notranslate\">TIME_ZONE</code></a>.</p>\n</aside>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.accessed_time\">\n<span class=\"sig-name descname\">accessed_time</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.accessed_time\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a naive <code class=\"docutils literal notranslate\">datetime</code> object containing the last\naccessed time of the file. For storage systems that aren’t\nable to return the last accessed time this will raise\n<code class=\"docutils literal notranslate\">NotImplementedError</code> instead.</p>\n<aside class=\"version-note version-deprecated\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">Deprecated since Django 1.10</p><p><span class=\"versionmodified deprecated\">Descontinuado desde a versão 1.10: </span>Use <a class=\"reference internal\" href=\"#django.core.files.storage.Storage.get_accessed_time\" title=\"django.core.files.storage.Storage.get_accessed_time\"><code class=\"xref py py-meth docutils literal notranslate\">get_accessed_time()</code></a> instead.</p>\n</aside>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.core.files.storage.Storage.created_time\">\n<span class=\"sig-name descname\">created_time</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.created_time\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a naive <code class=\"docutils literal notranslate\">datetime</code> object containing the creation\ntime of the file.  For storage systems that aren’t able to\nreturn the creation time this will raise\n<code class=\"docutils literal notranslate\">NotImplementedError</code> instead.</p>\n<aside class=\"version-note version-deprecated\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">Deprecated since Django 1.10</p><p><span class=\"versionmodified deprecated\">Descontinuado desde a versão 1.10: </span>Use <a class=\"reference internal\" href=\"#django.core.files.storage.Storage.get_created_time\" title=\"django.core.files.storage.Storage.get_created_time\"><code class=\"xref py py-meth docutils literal notranslate\">get_created_time()</code></a> instead.</p>\n</aside>\n</dd></dl>\n\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\">delete</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.delete\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Deletes the file referenced by <code class=\"docutils literal notranslate\">name</code>. If deletion is not supported\non the target storage system this will raise <code class=\"docutils literal notranslate\">NotImplementedError</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\">exists</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.exists\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns <code class=\"docutils literal notranslate\">True</code> if a file referenced by the given name already exists\nin the storage system, or <code class=\"docutils literal notranslate\">False</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\">get_accessed_time</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_accessed_time\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">New in Django 1.10</p></aside>\n<p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(em Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</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=\"(em Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\">NotImplementedError</code></a>.</p>\n<p>If <a class=\"reference internal\" href=\"/pt-br/1.10/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is <code class=\"docutils literal notranslate\">True</code>, returns an aware <code class=\"docutils literal notranslate\">datetime</code>,\notherwise returns a naive <code class=\"docutils literal notranslate\">datetime</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_available_name\">\n<span class=\"sig-name descname\">get_available_name</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em>, <em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">None</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 para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a filename based on the <code class=\"docutils literal notranslate\">name</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\">max_length</code>, if provided.\nIf a free unique filename cannot be found, a\n<a class=\"reference internal\" href=\"/pt-br/1.10/ref/exceptions/#django.core.exceptions.SuspiciousOperation\" title=\"django.core.exceptions.SuspiciousOperation\"><code class=\"xref py py-exc docutils literal notranslate\">SuspiciousFileOperation</code></a> exception will be raised.</p>\n<p>Se um arquivo com um <code class=\"docutils literal notranslate\">name</code> já existe, um “underscore” mais uma seqüência alfanumérica de 7 caracteres aleatórios são anexados ao nome do arquivo antes da extensão.</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\">get_created_time</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_created_time\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">New in Django 1.10</p></aside>\n<p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(em Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</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=\"(em Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\">NotImplementedError</code></a>.</p>\n<p>If <a class=\"reference internal\" href=\"/pt-br/1.10/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is <code class=\"docutils literal notranslate\">True</code>, returns an aware <code class=\"docutils literal notranslate\">datetime</code>,\notherwise returns a naive <code class=\"docutils literal notranslate\">datetime</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\">get_modified_time</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_modified_time\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">New in Django 1.10</p></aside>\n<p>Returns a <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(em Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</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=\"(em Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\">NotImplementedError</code></a>.</p>\n<p>If <a class=\"reference internal\" href=\"/pt-br/1.10/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is <code class=\"docutils literal notranslate\">True</code>, returns an aware <code class=\"docutils literal notranslate\">datetime</code>,\notherwise returns a naive <code class=\"docutils literal notranslate\">datetime</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\">get_valid_name</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.get_valid_name\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a filename based on the <code class=\"docutils literal notranslate\">name</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\">generate_filename</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">filename</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.generate_filename\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">New in Django 1.10</p></aside>\n<p>Validates the <code class=\"docutils literal notranslate\">filename</code> by calling <a class=\"reference internal\" href=\"/pt-br/1.10/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\">get_valid_name()</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\">save()</code></a> method.</p>\n<p>The <code class=\"docutils literal notranslate\">filename</code> argument may include a path as returned by\n<a class=\"reference internal\" href=\"/pt-br/1.10/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\">FileField.upload_to</code></a>.\nIn that case, the path won’t be passed to <a class=\"reference internal\" href=\"/pt-br/1.10/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\">get_valid_name()</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=\"(em Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">os.path</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\">listdir</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">path</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.listdir\"><span class=\"visually-hidden\">Link para esta definição</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\">NotImplementedError</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.modified_time\">\n<span class=\"sig-name descname\">modified_time</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.modified_time\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Returns a naive <code class=\"docutils literal notranslate\">datetime</code> object containing the last\nmodified time. For storage systems that aren’t able to return\nthe last modified time, this will raise\n<code class=\"docutils literal notranslate\">NotImplementedError</code> instead.</p>\n<aside class=\"version-note version-deprecated\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">Deprecated since Django 1.10</p><p><span class=\"versionmodified deprecated\">Descontinuado desde a versão 1.10: </span>Use <a class=\"reference internal\" href=\"#django.core.files.storage.Storage.get_modified_time\" title=\"django.core.files.storage.Storage.get_modified_time\"><code class=\"xref py py-meth docutils literal notranslate\">get_modified_time()</code></a> instead.</p>\n</aside>\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\">open</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em>, <em class=\"sig-param\">mode<span class=\"o\">=</span><span class=\"default_value\">'rb'</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.open\"><span class=\"visually-hidden\">Link para esta definição</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Opens the file given by <code class=\"docutils literal notranslate\">name</code>. Note that although the returned file\nis guaranteed to be a <code class=\"docutils literal notranslate\">File</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\">path</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.path\"><span class=\"visually-hidden\">Link para esta definição</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\">open()</code>. For storage systems that aren’t accessible from\nthe local filesystem, this will raise <code class=\"docutils literal notranslate\">NotImplementedError</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\">save</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em>, <em class=\"sig-param\">content</em>, <em class=\"sig-param\">max_length<span class=\"o\">=</span><span class=\"default_value\">None</span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.save\"><span class=\"visually-hidden\">Link para esta definição</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\">name</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\">max_length</code> argument is passed along to\n<a class=\"reference internal\" href=\"/pt-br/1.10/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\">get_available_name()</code></a>.</p>\n<p>The <code class=\"docutils literal notranslate\">content</code> argument must be an instance of\n<a class=\"reference internal\" href=\"/pt-br/1.10/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">django.core.files.File</code></a> or a file-like object that can be\nwrapped in <code class=\"docutils literal notranslate\">File</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\">size</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.size\"><span class=\"visually-hidden\">Link para esta definição</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\">name</code>.\nFor storage systems that aren’t able to return the file size this will\nraise <code class=\"docutils literal notranslate\">NotImplementedError</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\">url</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.core.files.storage.Storage.url\"><span class=\"visually-hidden\">Link para esta definição</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\">name</code>\ncan be accessed. For storage systems that don’t support access by URL\nthis will raise <code class=\"docutils literal notranslate\">NotImplementedError</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":"Referência da API","url":"/pt-br/1.10/ref/"},{"docname":"ref/files/index","title":"File handling","url":"/pt-br/1.10/ref/files/"}],"prev":{"docname":"ref/files/file","title":"O objeto File","url":"/pt-br/1.10/ref/files/file/"},"next":{"docname":"ref/files/uploads","title":"Uploaded Files and Upload Handlers","url":"/pt-br/1.10/ref/files/uploads/"},"formats":{"html":"/pt-br/1.10/ref/files/storage/","markdown":"/pt-br/1.10/ref/files/storage.md","json":"/pt-br/1.10/ref/files/storage.json"},"source":"https://github.com/django/django/blob/stable/1.10.x/docs/ref/files/storage.txt","official":"https://docs.djangoproject.com/pt-br/1.10/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","1.10","1.9"],"inLocales":["en","fr","ja","id","pt-br","es","el","pl"]}