{"id":857,"date":"2014-04-01T14:35:57","date_gmt":"2014-04-01T18:35:57","guid":{"rendered":"http:\/\/blog.uvm.edu\/ctl-projects\/?p=832"},"modified":"2014-04-01T14:35:57","modified_gmt":"2014-04-01T18:35:57","slug":"mediamanager-bug-fix-leads-to-enhancements","status":"publish","type":"post","link":"https:\/\/blog.uvm.edu\/waw\/2014\/04\/01\/mediamanager-bug-fix-leads-to-enhancements\/","title":{"rendered":"MediaManager bug fix leads to enhancements"},"content":{"rendered":"<p>The application at<\/p>\n<p><a href=\"https:\/\/www.uvm.edu\/htpasswd\/podcast_manager\">https:\/\/www.uvm.edu\/htpasswd\/podcast_manager<\/a><\/p>\n<p>was exhibiting strange behavior. Guy from COM had 607 Mb file, wouldn&#8217;t upload.<\/p>\n<p>Fixed and improved, can now upload up to 10Gb files (when used with a &#8216;modern&#8217; browser).<br \/>\nSome background &#8230;<\/p>\n<p>It\u2019s just a glorified file uploader, relying on plupload (1.5.8). \u00a0There is evidence (\/users\/c\/o\/comvideo\/public_html\/podcast_folder) that as of last October, it was working fine. Now, For a certain file size 343Mb &lt; N &lt; 607MB, upload succeeds in Safari and FireFox on MacOS; fails on Chrome Mac and Win, FireFox Win, and IE. It is setup to use HTML5 runtime, no chunking for all but IE. For IE, Silverlight and chunking.<\/p>\n<p>Chunking? Yes. Upload widget sends file in (now set to) 10Mb &#039;chunks.&#039; Each chunk is sent to the same php script, along with file name, chunk number, and total chunks. php script appends chunk \u00a0to file. This gets us around \u00a0the (UVM\/ETS\/SAA) imposed php max file size limit of 1Gb.<\/p>\n<p>Step forward<\/p>\n<p>I blamed it all on upgraded browsers and old plupload. So I created<\/p>\n<p><a href=\"https:\/\/www.uvm.edu\/htpasswd\/podcast_manager_dev\">https:\/\/www.uvm.edu\/htpasswd\/podcast_manager_dev<\/a><\/p>\n<p>with plupload 2.1.1 and chunking all the time. And here is what I discovered:<\/p>\n<p>The podcast_manager lives in \/shares\/uvmweb\/htdocs\/htpasswd\/ , which has SAFE_MODE turned off, and relies on WebAuth set_uid magic to allow the script to create files in the REMOTE_USER\u2019s home directory<\/p>\n<p>plupload sends the first chunk 0, upload.php \u00a0creates filename_part with mode \u2018wb&#8217;<\/p>\n<p>$out = fopen(&#8220;{$filePath}.part&#8221;, $chunk == 0 ? &#8220;wb&#8221; : &#8220;ab&#8221;);<\/p>\n<p>creates file and writes data to file. plupload sends next chunk 1, upload.php attempts to open file using mode \u2018ab\u2019, FAILS with a permission denied error, system crashes and burns. In fact, even trying to create a new file using mode \u2018ab\u2019 fails<\/p>\n<p>&nbsp;<\/p>\n<p>On Mar 28, 2014, at 10:27 AM, Benjamin Coddington wrote:<\/p>\n<blockquote><p>I just (this morning) fixed a problem where un-authenticated PHP could not open files with O_APPEND. \u00a0That shouldn&#8217;t have changed the behavior for this case because you are using the WebAuth authentication.<\/p><\/blockquote>\n<p>Well, it shouldn&#8217;t, but now it does work<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The application at https:\/\/www.uvm.edu\/htpasswd\/podcast_manager was exhibiting strange behavior. Guy from COM had 607 Mb file, wouldn&#8217;t upload. Fixed and improved, can now upload up to 10Gb files (when used with a &#8216;modern&#8217; browser). Some background &#8230; It\u2019s just a glorified &hellip; <a href=\"https:\/\/blog.uvm.edu\/waw\/2014\/04\/01\/mediamanager-bug-fix-leads-to-enhancements\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41826],"tags":[42758,647],"class_list":["post-857","post","type-post","status-publish","format-standard","hentry","category-wes","tag-boffins","tag-php"],"_links":{"self":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts\/857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/comments?post=857"}],"version-history":[{"count":0,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts\/857\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/media?parent=857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/categories?post=857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/tags?post=857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}