
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
django-uuid-upload-path
Advanced tools
Generate short UUIDs and use them as paths for uploaded media files in Django.
django-uuid-upload-path generates short UUIDs to use as paths for uploaded media files in Django.
uuid_upload_path
directory into your PYTHONPATH
. If using pip, run
pip install django-uuid-upload-path
.Generate a short, URL-safe UUID as follows:
::
from uuid_upload_path import uuid
uuid() // -> "hCdLEjlQQJW25-sXB3T_Gw"
To upload media files to short UUID filenames, just set upload_to
to uuid_upload_path.upload_to
.
::
from uuid_upload_path import upload_to
class YourModel(models.Model):
file = models.FileField(
upload_to = upload_to,
)
Django tries to ensure that all your uploaded files are given unique names on the filesystem. It does this by checking if a file with the same name exists before saving a new one, and adding a suffix if the new file would otherwise conflict with the existing one.
If you're saving files to disk using the built-in django.core.files.storage.FileSystemStorage
, this isn't much of a problem. However, if you're using a cloud file storage, such as storages.backends.s3boto.S3BotoStorage
, this uniqueness check can have a noticeable effect on the performance of file uploads. Worse, the default configuration of S3BotoStorage
is to overwrite existing files with the same name when uploading a new file!
By generating a unique filename for each uploaded file, django-uuid-upload-path removes the need for a costly uniqueness check, and avoids accidentally overwriting existing files on remote cloud storages.
Downloads and bug tracking can be found at the main project website <http://github.com/etianen/django-uuid-upload-path>
_.
The django-uuid-upload-path project was developed by Dave Hall. You can get the
code from the django-uuid-upload-path project site <http://github.com/etianen/django-uuid-upload-path>
_.
Dave Hall is a web developer, based in Cambridge, UK. You can usually find him on the Internet in a number of different places:
Website <http://www.etianen.com/>
_Twitter <http://twitter.com/etianen>
_Google Profile <http://www.google.com/profiles/david.etianen>
_FAQs
Generate short UUIDs and use them as paths for uploaded media files in Django.
We found that django-uuid-upload-path demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.