Need snapshot to FTP to overwrite the same name

Have some questions or having issues with your IP Camera(s), Post them here for the mods and other users to assist you with.
comsci
Posts: 5
Joined: Tue Apr 25, 2017 1:03 pm

Re: Need snapshot to FTP to overwrite the same name

Post by comsci »

If you're OK with uploading to a third party site, then this is what a number of users do with an account of the IP Camera FTP service that I'm developing. No need for image overwrite and stale images deleted automatically to maintain quota.

If you enable sharing on your account, then the latest image is available at a fixed url that can be included in your webiste: eg.
https://app.comsci.co.uk/imageserver/CC ... ird/latest

Accounts are currently free while in beta.

Try it out at
https://app.comsci.co.uk/camac
prinzlmeisl
Posts: 1
Joined: Mon Dec 28, 2020 8:23 pm

Re: Need snapshot to FTP to overwrite the same name

Post by prinzlmeisl »

If you have a Windows box running somewhere, and luckily I do, a few lines of Powershell script will do the trick, along with a scheduled task. This script will use the Amcrest HTTP API to download a snapshot image to a local folder, and subsequently iterate through all images in the image folder and upload them to an FTP server. This will normally be only one image, of course, the one that was just downloaded, unless you want to do something more complex.
I run this once per hour to upload a file to my web hoster.
The absence of this feature from the camera firmware is astounding.

Code: Select all


#image
$Dir="[image folder path]/"
$file = "[image name].jpg"

#camera
$web = "http://[camera url]/cgi-bin/snapshot.cgi?channel=1"
$user = "[camera user]"
$pass = "[camera password"

$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)

"Downloading snapshot..."
$uri = New-Object System.Uri($web)
$webclient.DownloadFile($uri, $Dir+$file)

#ftp server
$ftp = "ftp://[upload URL]/"
$user = "[ftp user]"
$pass = "[ftp password]"

$webclient = New-Object System.Net.WebClient

$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)

#list every image, upload all in folder
foreach($item in (dir $Dir "*.jpg")){
"Uploading $item..."
$uri = New-Object System.Uri($ftp+$item.Name)
$webclient.UploadFile($uri, $item.FullName)
}
Post Reply