I would like all imagefield images to be saved on a different location, specifically Amazon S3.

Is it possible to bypass saving the image in the files directory and have them offloaded to an S3 bucket? The cloudfront module places all imagecache presets on S3, but the original images still live on the drupal files directory. I would like ALL images and imagecache files saved on the S3...is this possible?

Any help greatly apreciated!

Thanks!

Comments

adam_c’s picture

i too would like this

quicksketch’s picture

This isn't possible with either FileField or ImageField in Drupal 6. The reason for this is because the primary mechanism for CCK storing this information revolves around the file FID, stored in Drupal core's "files" table. The files table only supports relative path storage.

HOWEVER, this is not the case in Drupal 7. In Drupal 7, FileField module has been merged into core (it's just called File module now). Combined with the new File API, all files are stored as URIs instead of file paths. This means that instead of "sites/all/files/path/filename.png", files are now stored as "public://path/filename.png". You can choose which fields are mapped to which services on a per-field basis. So you can have one file field for private files and one for public files. Using add-on modules, you can directly upload to services such as S3 or Flickr.

Unfortunately this is all in the future. Your options today consist of either just using a Link field and entering the URL for your file, or using FileField and combine it with Media Mover to transfer the file to some other storage on cron jobs after it has been uploaded.

obrienmd’s picture

^ Agreed on the D7 stuff, but perhaps you could mount the S3 bucket as a specific subdirectory of /files if you have that much control on the server?

adam_c’s picture

Im intrigued.

I have full control of the server but im not sure what you mean by mounting buckets in the files directory, could you please elaborate a little?

obrienmd’s picture

See http://code.google.com/p/s3fs/wiki/FuseOverAmazon - This allows you to use S3 as a Linux FUSE filesystem (userspace filesystem). If you need further instructions, let me know what distro of Linux your server is running.

adam_c’s picture

Its windows :(

I actually prefer windows but would have really liked this feature

adam_c’s picture

Thinking about it, is this actually an effective way of transfering data?

My assumption of the above is that:

You upload an image to your server
It gets transfered to S3
Someone views a page with that image
Image gets pulled from S3 to your server
Image then gets sent from your server to the client

Is that right?

Ideally you would want the image being transfered directly from S3 to the client.

obrienmd’s picture

When "mounting" a bucket in the files directory, the uploads to that dir would actually go directly to s3, and downloads from would come directly from s3. Though bandwidth you still hit your server, not sure how to mitigate that as the client cannot get direct secure access to s3, permissions would be a mess I think on the write side. If you're looking for something more direct, you're looking at CDN-type stuff, again mostly focused on the download side rather than upload...

I'm rambling...

For windows mount, check this out: http://coolthingoftheday.blogspot.com/2006/12/s3-drive-mount-your-amazon...

I know nothing about this ^, but I'm sure you could mount as a drive, then symlink/junction that drive (lookup NTFS junction) to a folder in the files dir.

quicksketch’s picture

Status: Active » Fixed

I'm moving this issue to "fixed", since the question has been answered within the scope of ImageField.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.