I've included S3FS module in Drupal 7. I'm able to store files by using S3FS as a field of a node.

Now, I need to store a file on S3 bucket when a cron job is executed. How can I programmatically use the module?

  • I would expect the techniques and maybe helper functions to be in the s3fs module.
    – mona lisa
    Commented Feb 13, 2016 at 1:32
  • Is there any sample code available to understand the usage of those helper function? I didn't find any so far.
    – Vish
    Commented Feb 16, 2016 at 19:23
  • I'm able to connect to S3 bucket via creating a mount directory by using s3fs-fuse. I was expecting to use some calls or S3FS directly in the code.
    – Vish
    Commented Feb 17, 2016 at 21:09

2 Answers 2


I used the following command to write the file. The system picks up the S3 connection (as I mentioned earlier that I'm able to store file as a field of a node):

file_put_contents('s3://Dir1/output.json', $jsonStr);
  • This answer is helpful and contains the gist of the solution but needs a bit of expansion. You should explain that the "s3://" prefix is a stream wrapper which allows filesystem operations to be performed transparently on the bucket using standard PHP file functions. Commented Nov 18, 2023 at 17:53

I created this module that copies images, css, js to s3 https://www.drupal.org/sandbox/mikeytown2/2678270

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.