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

save_file() saves file twice #26615

Open
s-aga-r opened this issue May 30, 2024 · 0 comments
Open

save_file() saves file twice #26615

s-aga-r opened this issue May 30, 2024 · 0 comments
Labels

Comments

@s-aga-r
Copy link
Contributor

s-aga-r commented May 30, 2024

from frappe.utils.file_manager import save_file


fname = "unique-name.png"
content = (
    b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00"
    b"\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\r"
    b"IDATx\x9cc\xf8\xff\xff?\x03\x00\x08\xfc\x02\xfe\xa7\x9a\xa0"
    b"\xa0\x00\x00\x00\x00IEND\xaeB`\x82"
)

save_file(fname, content, None, None, is_private=1)

^ creates two files in the filesystem on the first execution. These files are named unique-name.png and unique-name91a8f8.png. The file doc gets linked with the unique-name91a8f8.png.

The save_file saves the file in the disk if it does not exist. The same file will be saved again by the File.save_file().

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

No branches or pull requests

1 participant