Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatability with Django safe_join and Windows (leading "/" on file path) #1015

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

johnvorsten
Copy link

Even though you pass the upload_to argument which gives a unix-style path (something like /save/path) the django utility makes sure the root of that save path matches the base path for the operating system :(. The dropbox SDK does not like a drive prefixed to the desired save path (AKA C:/path/file.name is not a valid save directory for dropbox).

johnvorsten and others added 4 commits February 23, 2020 14:01
onto the user specified save path. The django utility
django.utils._os.safe_join is used if the operating system is not
windows 'nt'. If the operating sytem is windows 'nt' then the passed
name will be checked against a path style specified for the dropbox SDK.
AKA the root is kept as '/' and no drive is prefixed
@wild-boomerang
Copy link

wild-boomerang commented Jun 11, 2021

@johnvorsten, are you sure that import os and

class SuspiciousFileOperation(Exception):
    pass

are not needed to add?
As for me, your code didn't work until I added this code.
Thanks anyway! It works for me.

final_path = os.path.join(self.root_path, name).replace('\\', '/')

# Separator on linux system
sep = '//'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't sep on Linux (Unix) just a single slash (/)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants