I'm trying to write a script that will insert products into a Drupal site programmatically. That part of the script isn't the problem, I have it mostly working. The issue I'm running into is how do I determine the storage scheme / file stream for a particular field?
Let me be more specific... I have an image field, and I know how to upload images into the site's storage area using the file_save_data function.
The issue is that some of my images are stored in different file storage schemes than others. Some may be stored in public://, and others are stored in s3:// (using the Amazon S3 module).
I know the information is in the db somewhere, because the GUI pulls it out and puts it into a form when I edit the field settings. I'm trying to figure out how to get that same data for a particular field through a php script.
So right now I have something like:
$field_storage_scheme = "s3";
$dest=$field_storage_scheme."://".$name;
$file = file_save_data(file_get_contents($url), $dest, FILE_EXISTS_REPLACE);
I need to be able to do something like:
$field_storage_scheme = get_field_storage_scheme('field_name');
To get either public, private, s3, or whatever else the field has configured for it's storage in the db.