3 of 3
3
Simple S3 Upload Extension now on EE2 (current version: 1.2.1)
Posted: 10 July 2010 07:12 PM   [ Ignore ]   [ # 37 ]  
Grad Student
Rank
Total Posts:  50
Joined  03-31-2009

Thanks, Ty, I really appreciate your quick replies to my questions!

One of the reasons we need to preserve the filename is that we have a few PDF and Word documents that people need to download as part of a specialised workflow, and it is important that each file retains the original name. If the only things we were uploading were images for display, the renaming wouldn’t be an issue, and with images and certain other files I can certainly see the value in the timestamp, as you point out.

Looking at your code, though, raises one further little question: I’m not a PHP guy, so I’ve probably got it completely wrong, but the two lines you’ve highlighted make me think that the the timestamp should be added at the start of the filename.  So “file.pdf” would become something like “1234567890-file.pdf”. If so, I must be doing something wrong, because the file that ends up on S3 is actually “1234567890-.pdf” (that is, just the timestamp plus a dash). All references to the original filename are being removed, though the correct name is still being returned by the {custom_field:name} tag, though.

A good compromise for us, in fact, might be an option to append the timestamp at the *end* of the filename, which would solve both issues. In other words, we would be happy enough if “file.pdf” became “file-1234567890.pdf”. That would keep the filename for the workflow, avoid the issue of the file being overwritten, and have the added bonus that the timestamp might also come in handy for tracking what version of a file people had been using (some of the files will be returned to us as part of the workflow).

Anyway, I might have a bit of a play to see what we can come up with ... hopefully without breaking the whole thing! wink

If you don’t mind taking feature requests, though, do you think there’s any chance that file naming conventions could be introduced as a field setting? If that was possible, and not too much extra work, I think it would certainly take care of our own particular issue, and maybe even avoid any other potential concerns that others might have in the future.

Whatever happens, though, thanks heaps for all your help with this!

Profile
 
 
Posted: 10 July 2010 08:33 PM   [ Ignore ]   [ # 38 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1848
Joined  12-18-2008

that is one feature I’ve had on my list of thoughts for some time now.  I’m not sure when I’ll be able to implement it though.

 Signature 

EE Pro Network
eMarketSouth - full service web design, development, and SEO
ExpressionEngine consulting services - SQL queries, .htaccess rewrites, template optimization, jQuery/AJAX, and more!
our add-ons - please “favorite” and rate our products on devot:ee if you like our work. smile

Profile
 
 
Posted: 11 July 2010 06:14 AM   [ Ignore ]   [ # 39 ]  
Grad Student
Rank
Total Posts:  50
Joined  03-31-2009

As long as it’s on your list of thoughts, I’m happy ... because you make me very confident that it will indeed come one day! grin

Seriously, though, I really do appreciate the time you put into developing your product, and the speed with which you manage it (it’s if’s a relatively simple fix, of course). I have had experiences wher other products sometimes put things waaaay down on their feature list, even if it might only take a short time (like, for example, when you added the custom headers fix).

So thanks heaps
Andrew Macpherson
Sydney, Australia

Profile
 
 
Posted: 11 July 2010 06:27 AM   [ Ignore ]   [ # 40 ]  
Grad Student
Rank
Total Posts:  50
Joined  03-31-2009
ender - 10 July 2010 10:46 AM

look for the following lines in the ft.simple_s3_uploader.php file (they’ll be near the top of the _upload_to_s3() method:

$aws_object  preg_replace("/[^a-z0-9.]+/i""-"time("-" $pathinfo['filename'"." $pathinfo['extension']);
$aws_thumb   preg_replace("/[^a-z0-9.]+/i""-"time() . "-" $pathinfo['filename'"-thumb." $pathinfo['extension']); 

you can remove the time() part of the expression if you need to alter this behavior.

You may have your reasons for doing this, but note that the original filename is still available to you via the {my_custom_field:name} template tag.  All template tags can be found here.  If multiple people are going to be uploading files, the timestamps ensure that nobody overwrites anyone else’s stuff.

You’ll have to forgive me, but I can’t seem to get things the way I want them. Nothing I’ve tried so far has given me just the filename. There must be something I’m doing wrong, but I can’t figure it out. If you ever do get a bit of time, I’d really appreciate it if you could double-check what I really do need to do.

As I mentioned before, the original version doesn’t give me any trace of the filename when uploaded to S3. It just gives the timestamp ... so removing the timestamp bit just leaves a blank file, or a “-thumb.jpg”.

Cheers
Andrew

Profile
 
 
Posted: 12 July 2010 09:09 AM   [ Ignore ]   [ # 41 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1848
Joined  12-18-2008

it appears that the pathinfo() PHP function on EngineHosting doesn’t work quite like it does everywhere else I’ve tested.  Perhaps they’re running an older version of PHP 5. After digging through the docs, it appears that the filename option was added to the pathinfo function in 5.2.

I’ve modified the extension and will send you a copy via PM for you to test, Andrew.  Please let me know if it solves the filename issue on EngineHosting as I don’t have access to a server running an older version of PHP at the moment.

 Signature 

EE Pro Network
eMarketSouth - full service web design, development, and SEO
ExpressionEngine consulting services - SQL queries, .htaccess rewrites, template optimization, jQuery/AJAX, and more!
our add-ons - please “favorite” and rate our products on devot:ee if you like our work. smile

Profile
 
 
   
3 of 3
3