₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,137 members, 8,420,520 topics. Date: Thursday, 04 June 2026 at 11:18 PM

Toggle theme

Help! Filesystem Questions To Pythonians - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp! Filesystem Questions To Pythonians (814 Views)

1 Reply (Go Down)

Help! Filesystem Questions To Pythonians by webcalculator(op): 9:53am On Oct 26, 2013
Please how can i load a user saved file e.g image and associate it to a particular user in my website. Also how can i allow a user to create a gallery of images which will be associated to a listing. I'm a newbie to programing and i hav a project i'm learning on and this seems to be my greatest problem. I'm developing with pyramid webframework but if you knw hw i can do this in other frameworks please don't hesitate to let me knw. Thanks and God bless you
Re: Help! Filesystem Questions To Pythonians by Ajibel(m): 7:19am On Oct 27, 2013
webcalculator: ....I'm a newbie to programing and i hav a project i'm learning on and this seems to be my greatest problem.
excuse me sir, is the project from a tutorial you are reading or a project you conceivedhuh
Re: Help! Filesystem Questions To Pythonians by webcalculator(op): 6:22pm On Oct 27, 2013
Ajibel: excuse me sir, is the project from a tutorial you are reading or a project you conceivedhuh
A project i concieved.
Re: Help! Filesystem Questions To Pythonians by bb6xt(m): 11:49pm On Oct 27, 2013
Since each user will have a number of images to which s/he alone have access I would suggest storing uploaded images in a location inaccessible to your web server but to which your app has read/write privilege. To bind each image to a particularl user u may prefix d file name with d user's unique ID then save d file full path in db. To display d pix simply read d file as binary using data = open('filename', 'rb') return data as d response body setting d mime type appropriately. I've never used Pyramid but here is how u may do it in Django:
#in views.py
from django.http import HttpResponse
def serve_image(filename):
data = open(filename, 'rb')
return HttpResponse(data, mimetype ='application/jpeg')
Re: Help! Filesystem Questions To Pythonians by webcalculator(op): 6:19pm On Oct 29, 2013
bb6xt: Since each user will have a number of images to which s/he alone have access I would suggest storing uploaded images in a location inaccessible to your web server but to which your app has read/write privilege. To bind each image to a particularl user u may prefix d file name with d user's unique ID then save d file full path in db. To display d pix simply read d file as binary using data = open('filename', 'rb') return data as d response body setting d mime type appropriately. I've never used Pyramid but here is how u may do it in Django:
#in views.py
from django.http import HttpResponse
def serve_image(filename):
data = open(filename, 'rb')
return HttpResponse(data, mimetype ='application/jpeg')
wow, thanks, especialy for storing the image outside the serve n storing the ful path in db. I never thought of those. I wil gv it a try. Thanks once again
Re: Help! Filesystem Questions To Pythonians by Creatrixity(m): 10:58pm On Nov 03, 2013
@webcalculator,Are you using the django framework to write your web applications?
Re: Help! Filesystem Questions To Pythonians by webcalculator(op): 4:21pm On Nov 04, 2013
Creatrixity: @webcalculator,Are you using the django framework to write your web applications?
No. I'm using Pyramid
1 Reply

Where Can I Get Java Real Questions To Enchace Ma Performance[Project Help Request]: Filesystem search with output in HTML format.234

Signature Pad Integration To .netDrupal EbookHow Can I Browse Free On My Tab With Airtel Sim