What are the urls of the file?

91 views
Skip to first unread message

I H.

unread,
Jun 6, 2017, 12:15:32 PM6/6/17
to django-filer
Hello,

I would like to work with this application differently and I wonder if it would be possible. I would like to upload directly my files into the media folder.

Then, I want to provide a link on my webpage. Is that possible to do that with django-filer?

Thanks

Hassan Mian

unread,
Jul 24, 2017, 5:52:33 AM7/24/17
to django-filer
Hi, 

You can achieve that by manually creating Filer instances for you files upload in your media folder. Just iterate over those files and run something like this:

file_url = '' #PATH TO YOUR FILE
folder_name
= 'the_folder_name'
name_of_file
= 'whatever_u_want_to_call_the_file'
description_of_file
= 'Description'


file_instance
= File(open(file_url))
folder
, created = Folder.objects.get_or_create(name=folder_name)


name
= u'{}'.format(name_of_file)


filer_instance
, filer_instance_created = FilerImage.objects.get_or_create(
    name
=name,
    folder
=folder,
    description
=description,
)
filer_instance
.file = file_instance
filer_instance
.save()
file_instance
.close()
Reply all
Reply to author
Forward
0 new messages