I am using the module Node Export (https://www.drupal.org/project/node_export) in conjunction with the field collection deploy module (https://www.drupal.org/project/field_collection_deploy) to export and import nodes with field collections.
My field collection have image fields which refers to an S3 bucket. It is configured correct and I can upload and save images without issues.
I am extending the field collection deploy module to be able to save images from an exported node. The exporting of the node is fine. I can see the image field being exported correctly:
Array
(
[und] => Array
(
[0] => Array
(
[fid] => 136712
[uid] => 1
[filename] => 200px_readingWithTeddyBEar.gif
[uri] => s3://test/200px_readingWithTeddyBEar.gif
[filemime] => image/gif
[filesize] => 40316
[status] => 1
[timestamp] => 1432006397
[uuid] => 9d716b65-2eee-42dc-a50d-35b1eb9ef699
[rdf_mapping] => Array
(
)
[alt] =>
[title] =>
[width] => 200
[height] => 300
)
)
)
I am, however having issues trying to import the image.
To try and import and save the image, I have to use the entity metadata wrapper. I followed the instructions here http://dropbucket.org/node/1593 to set the image field in an the wrapper. It sets the image however when I view or edit the node in the target server, I see that the image is saved locally:
http://localhost:8888/test-p01/sites/default/files/fileqov1j3
Would anyone know what I should do to ensure the image or URI is set to the S3 bucket?
I tried modifying the file object but to no avail...
Any pointers or assistance is greatly appreciated!
Comments
Comment #1
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedAre you following that example exactly? The first line is saving the image data to a local file, and you shouldn't need that. You should just be able to set $file_path to 's3://...'.
Also, since you're doing work on the site anyways, I'd suggest updating to the 7.x-2.x branch. I'll be tagging a stable release today or tomorrow.
Comment #2
ajlow CreditAttribution: ajlow commentedHi @deviantintegral,
Yes, I followed the example exactly. Also, thank you for pointing out that the image got saved locally; that helped me figure out my issue.
To solve my issue, I used the system_retrieve_file function to copy from my source S3 bucket to my destination S3 bucket: (https://api.drupal.org/api/drupal/modules!system!system.module/function/...). I used the TRUE flag and FILE_EXISTS_REPLACE for my instance.
This function returns a file object which I can then set to the entity metadata wrapper:
Once done, the image gets set properly! :)
Thank you very much for your quick response and help! It is very much appreciated! :)
Comment #3
deviantintegral CreditAttribution: deviantintegral at Lullabot for NBCUniversal commentedGood stuff. Thanks for the update!