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

  • SEARCH
  • Home
  • 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 6068555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:43:39+00:00 2026-05-23T09:43:39+00:00

I have an axis camera which POSTS data to an address I give it.

  • 0

I have an axis camera which POSTS data to an address I give it. I would like it to post data to a rails application, but I haven’t found any examples of how to do that. The only information I have to work with is the header for the post request. I pulled a few things out, but here’s what I got:

REQUEST_METHOD = POST
QUERY_STRING = 
CONTENT_TYPE = image/jpeg
DOCUMENT_ROOT = /var/www/staging/public
REQUEST_URI = /camera/1/images?
SCRIPT_NAME = 
PATH_INFO = /camera/1/images
HTTP_CONTENT_DISPOSITION = attachment; filename="image09-12-16_21-16-28-90.jpg"
_ = _

As far as I can tell, The request itself contains the JPEG Image.

Axis publishes the following as a CGI script to save the images. It works, but I want it to be a part of my Rails app:

#!/usr/bin/perl -w
my $upload_dir = "/var/www/cgi-bin/upload/";

print "Content-Type: text/plain\r\n\r\n";
print "Upload OK\r\n";

my $file_name = $ENV{'HTTP_CONTENT_DISPOSITION'};
$file_name =~ s/^attachment; filename=\"(.*)\"$/$1/;

open (IMG_FILE, "> $upload_dir$file_name") or die "can't open >$upload_dir$file_name";
binmode(IMG_FILE);
while (<STDIN>) {

print IMG_FILE $_;

}
chmod 0666, "$upload_dir$file_name";

exit 0;

So the filename is in ENV{‘HTTP_CONTENT_DISPOSITION’}, which is clear in both the headers and the sample code. It seems, from the perl script, that the image data is all contained in STDIN. I have tried the following in rails:

imagefile = File.new("test_file.jpg","w+")
imagefile << STDIN.read
imagefile.close

but it did not work. The file test_file.jpg was empty.

Is there anything I am mission? Does anyone know how to save the request data as a file?

Does anyone know of any good libraries that allow http upload from Axis webcams?

  • 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-05-23T09:43:39+00:00Added an answer on May 23, 2026 at 9:43 am

    Rails does not use a CGI interface with stdin/stdout etc. The body of a submitted request can be found in request.body, so in the above change STDIN.read to request.body.read and you should be fine.

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

Sidebar

Related Questions

I have an axis on a 3D plot which I would like to plot
I have a java application that has Web Services published using Axis. With the
I have a piece of code looking like this : TAxis *axis = 0;
So I have a tiny header image that repeats on the x axis, but
I have a scene that stores vertices in 3D space. What i would like
I have data that always looks something like this: alt text http://michaelfogleman.com/static/images/chart.png I need
I have a series of performance tests I would like to show as a
I have an image that I capture from an ip camera and post it
I have a web application running on port :80, and I have an Axis
I have a very rudimentary camera which generates 3 vectors for use with gluLookAt(...)

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.