And apparently this is what is causing the issue on Linux the wrong path and the folder that does not have the permission. If the above path problem is corrected and if the file is properly saved and thumbnail created then I guess the Linux disk issue might be resolved too.
Please suggest Regards, Rahul On Friday, August 30, 2019 at 12:51:41 AM UTC+5:30, Rahul wrote: > > Hi Val and Dave, > > Have a look at the code below - the line foto_path=... below works but it > uploads the photos to "web2py\applications\artpicstatic\user_uploads" > folder instead of web2py\applications\artpic\static\user_uploads folder. It > also generates the thumbnail file. Now if I use *foto_path = > os.path.join(request.folder + "static/user_uploads/" + upload_pic)* it > shows the right path after normalization but does not upload the photo at > all. And since it does not upload the photo the rest of the code fails to > generate thumbnails etc and throws this error . m using windows 10 with > python 2.7.13 > > - <type 'exceptions.IOError'> [Errno 2] No such file or directory: > 'E:\\web2py_src\\web2py\\applications\\artpic\\static\\user_uploads\\fotoz.upload_photo.82bfeee5a1affabd.3033372e4a5047.JPG' > > CODE: > ------- > #foto_path = (request.folder + "static/user_uploads/" + upload_pic) > print ("----------------") > foto_path = (request.folder + "static/user_uploads/" + upload_pic) > print "Foto Path: ", foto_path > > normal_foto_path = os.path.normpath(foto_path) > print "Normal Foto Path: ", normal_foto_path > > infile = normal_foto_path > print "infile: " , infile > > thumbnail_filename = ("%s" % recordsID + ".thumbnail.jpg") > print "thumbnail_filename :", thumbnail_filename > > outfile_path = os.path.join(request.folder, "static/thumbs/" + > thumbnail_filename) > print "outfile_path: ", outfile_path > > normal_outfile_path = os.path.normpath(outfile_path) > print "normal_outfile_path ", normal_outfile_path > > outfile = normal_outfile_path > print "outfile: ", outfile > ----------- > OUTPUT ITERATIONS: > > [1] > > Foto Path: > E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG > Normal Foto Path: > E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG > infile: > E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.8c9837615e4fa932.3035382e4a5047.JPG > thumbnail_filename : 64.thumbnail.jpg > outfile: > E:\web2py_src\web2py\applications\artpic\static\thumbs\64.thumbnail.jpg > ---------------- > [2] > > Foto Path: > E:\web2py_src\web2py\applications\artpicstatic/user_uploads/fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG > Normal Foto Path: > E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG > infile: > E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.838dbfb13f66470d.3030312e4a5047.JPG > thumbnail_filename : 65.thumbnail.jpg > outfile_path: > E:\web2py_src\web2py\applications\artpic\static/thumbs/65.thumbnail.jpg > normal_outfile_path > E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg > outfile: > E:\web2py_src\web2py\applications\artpic\static\thumbs\65.thumbnail.jpg > > ------------ > [3] > > infile: > E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG > thumbnail_filename: 79.thumbnail.jpg > outfile: > E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg > thumbpath: > E:\web2py_src\web2py\applications\artpic\static\thumbs\79.thumbnail.jpg > Cannot create thumbnail (un-recognized format) for: > E:\web2py_src\web2py\applications\artpicstatic\user_uploads\fotoz.upload_photo.862f9808c7622ca7.3033372e4a5047.JPG > > > SCREENSHOT > > > > > CODELISTING IS ATTACHED > > Looks like a simple answer but feels like my code is badly written... > > Regards, > > Rahul > > > > > > > > > > On Thursday, August 29, 2019 at 2:17:49 AM UTC+5:30, Val K wrote: >> >> It is no need to use different code for win/linux, since it is Python! >> There is os.path.normpath(your_path) that does all stuff with slashes, I >> have app that works on both platforms just fine (without platform checking >> at all) >> My way - always use '/' in path, and at the end of all manipulations >> performs normalisation: path = os.path.normpath(path) >> And keep in mind that os.path.join() also works with filenames, so you >> can just os.path.join('foo', 'bar', 'baz.thumbnail.jpg') >> >> >> >> On Wednesday, August 28, 2019 at 9:05:11 PM UTC+3, Rahul wrote: >>> >>> Hi Dave, >>> >>> upload_pic is the form variable that user specifies for uploading the >>> file from local disk. Basically it is the filename. I removed the braces for >>> outfile = (thumbpath) >>> but this is still not working. Any more suggestions ? >>> >>> >>> Regards >>> Rahul >>> >>> On Tuesday, August 27, 2019 at 2:21:45 PM UTC+5:30, Rahul wrote: >>>> >>>> Hey Dave, >>>> I was facing issues with path storage in a db field so I >>>> started using this method. I dont need outfiles curly braces will revisit >>>> the code today if possible and get back with the details. This is my >>>> modified code, previous one was straight forward and streamlined code and >>>> was using simple code.Thanks for the questions I’ll try getting in >>>> details. >>>> >>>> Regards, >>>> >>>> Rahul >>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2f1bdd71-367d-426a-8ce8-e378ac6a491b%40googlegroups.com.