Re: [development] Shortening file names downloaded from webpage
Hi, Any webpage contains a lot of images, I am not aware of the time complexity of the function implementation, but won't it will be an overkill to generate so many md5 hashes? Looking forward. Message: 1 Date: Mon, 14 Sep 2009 21:16:12 +0530 From: nitin gupta <nitingupta.iitg@gmail.com> Subject: [development] Shortening file names downloaded from webpage To: development@drupal.org Message-ID: <4f59ac610909140846x5efff3bai3bc4a5deb5054b37@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hello, I am maintaining a module FeedAPI ImageGrabber. It downloads a relevant image from a webpage of the feed-item and stores it along with the node. I found that the module sometimes gave the 'filename too long error' ( http://drupal.org/node/505964). It happens because I was saving the image file with the name as basename($image_url). But to solve the issue, I am now trying this code to shorten the filename. $arr = parse_url($image_url); $filename = basename($arr['path']); This code solves the problem by removing the query and fragments of the url. Does anyone know of any better way to handle this? Can anyone point out any issues with this code? Regards, Nitin Kumar Gupta http://publicmind.in/blog
Someone correct me if I am wrong, but I doubt it. I just wrote up a quick script on my PC that MD5's 1000 40 character strings - it executes in 0.00061 seconds. I need to do about 2 million until the script hits the one second mark. Unless you are processing an extremely large amount of images, I would say the overhead of calling md5() can be ignored. - Frederik 2009/9/15 nitin gupta <nitingupta.iitg@gmail.com>
Hi,
Any webpage contains a lot of images, I am not aware of the time complexity of the function implementation, but won't it will be an overkill to generate so many md5 hashes?
Looking forward.
Message: 1 Date: Mon, 14 Sep 2009 21:16:12 +0530 From: nitin gupta <nitingupta.iitg@gmail.com> Subject: [development] Shortening file names downloaded from webpage To: development@drupal.org Message-ID: <4f59ac610909140846x5efff3bai3bc4a5deb5054b37@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
Hello, I am maintaining a module FeedAPI ImageGrabber. It downloads a relevant image from a webpage of the feed-item and stores it along with the node. I found that the module sometimes gave the 'filename too long error' ( http://drupal.org/node/505964). It happens because I was saving the image file with the name as basename($image_url).
But to solve the issue, I am now trying this code to shorten the filename.
$arr = parse_url($image_url); $filename = basename($arr['path']);
This code solves the problem by removing the query and fragments of the url. Does anyone know of any better way to handle this? Can anyone point out any issues with this code?
Regards, Nitin Kumar Gupta http://publicmind.in/blog
participants (2)
-
Frederik Grunta -
nitin gupta