Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,873 members, 7,828,113 topics. Date: Wednesday, 15 May 2024 at 01:15 AM

Help! Filesystem Questions To Pythonians - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help! Filesystem Questions To Pythonians (709 Views)

Where Can I Get Java Real Questions To Enchace Ma Performance / [Project Help Request]: Filesystem search with output in HTML format. (2) (3) (4)

(1) (Reply) (Go Down)

Help! Filesystem Questions To Pythonians by webcalculator(m): 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 conceived
Re: Help! Filesystem Questions To Pythonians by webcalculator(m): 6:22pm On Oct 27, 2013
Ajibel:

excuse me sir, is the project from a tutorial you are reading or a project you conceived
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')

2 Likes

Re: Help! Filesystem Questions To Pythonians by webcalculator(m): 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(m): 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)

How Is It That My Followed Boards Is Showing Wrongly? / Cctv Installations And Training........ / Ccna Subnetting Help!!!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.