Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9031897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:50:42+00:00 2026-06-16T07:50:42+00:00

So here is my code. Looks like the typical fog code. prefix = ‘data:image/png;base64,’

  • 0

So here is my code. Looks like the typical fog code.

prefix = 'data:image/png;base64,'
png = Base64.decode64(data[prefix.length, data.length-1])

aws_settings = YAML.load_file(RAILS_ROOT + "/config/amazon_s3.yml")[RAILS_ENV] rescue nil
if aws_settings
  connection = Fog::Storage.new(
    :provider => 'AWS',
    :aws_access_key_id => aws_settings['access_key_id'],
    :aws_secret_access_key => aws_settings['secret_access_key']
  )

  directory = connection.directories.get(aws_settings['bucket_name'])

  filename = "#{quiz_id}/#{user_id}_#{question_id}.png"
  file = directory.files.create(
    :key => filename,
    :body => png,
    :public => true
  )
end

the problem is when I call file.public_url I will randomly get one of two different urls. Either I will get:

https://bucket_name.s3.amazonaws.com/19/235_146.png

or

http://s3.amazonaws.com/bucket_name/19/235_150.png

While I don’t care one way or the other, I would like the url to be consistent.

Does anyone know how to remedy this issue? Am I doing something wrong in my code?

I should also mention that I’m doing this inside a Delayed::Job. It seems to always give me the https version when I do this as a normal method call. But when I stick it into Delayed Job is when I get the randomness. Very strange.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:50:43+00:00Added an answer on June 16, 2026 at 7:50 am

    Wow, this is kind of embarrassing.. This has turned into a lesson about delayed jobs. Apparently it had cached my old code where I was hard coding the url string to store it off. Like this:
    url = “http://s3.amazonaws.com/bucket_name/{quiz_id}/{user_id}_{question_id}.png”

    I later changed it to this:
    url = file.public_url

    Fog does default to that string if your bucket name is not dns compliant. That is why I was so confused as to why this was happening. So yeah, just old cached code that was getting used. I shut down delayed jobs and started it back up again and problem be gone.

    The way I was able to figure it out was I was looking at the delayed jobs log and noticed it still has some old puts statements getting printed in there. That is when it clicked. :]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen this web beacon image here The code looks like this: header(
here is what my code looks like i have two forms: class Form_1 extends
So I have some PHP code that looks like: $message = 'Here is the
Here's my regex code: preg_match_all('/background[-image]*:[\s]*url\([|\']+(.*)[|\']+\)/', $css, $matches, PREG_SET_ORDER); It looks for CSS that looks
A typical code fragment obtained from the YouTube embed feature looks like this: <object
Basic question here - I have many lines of code that look something like:
EDIT - The code looks strange here, so I suggest viewing the files directly
Really simple question here but bugging me for long enough to ask. Code looks
I have a problem with my error handling... (Using VS2010Express) My code looks like
Somewhat my code looks like below: static int myfunc(const string& stringInput) { string word;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.