[App] Image Poster

large

Description

Adds support for posting Image Token’s to a web site. Example use is for storing camera images on a web server.

Usage

  1. Add a flow Send a Image
  2. Add the Image token
  3. Add a URL
  4. Run and check the server

URL Receiver

You need to create a page on the “other side” that can receive a Form POST. Image will be stored with the ID “image”. Here you can find a simple example Upload it to your server and create a folder named images. Then point it out from the Flow e.g. http://yoururl.com/sendImage.php There is some simple logging done.

If you need a simple Gallery this one can be used: Simple Gallery

Links:

Supported devices

All devices that can post a Image Token

Supported Languages:

  • English
1 Like

I gave the app a try, but it doesn’t seem to work completely. I have a PHP file on my web server ready to receive IMG files. I tested this PHP file through another method so I’m 99% sure it should work with this app. I made some logging on this website (like in your example) to check if something happened.

When I sent for example the last snapshot of my Ring doorbell with this app, I can see the action card is busy for approx. 2 seconds and after that shows a green checkmark. But it doesn’t trigger the PHP file. Even the log shows not a single entry (no success nor any error).

-edit: if you want, I can send you a diagnostic report-

Now that I’ve tested it a little bit more, I can conclude that it doesn’t seem to work for big(?) images. Snapshots from my Ring doorbell are not sent with this app, while smaller images are sent to my PHP and stored succesfully. Is there some known limitation to sending large files?

Hmm, have just tried with the images from my camera and I guess they are quite small. There is a known PHP settings that limits uploads to a PHP page to 2MB. Maybe it is this setting hitting the limit? There is a check you can do in the sample code I have that you can just add to your:

if ($file_size > 2097152) {
$errors = ‘File size must be exactly 2 MB’;
}

You can change this in your php.ini file: https://www.a2hosting.com/kb/developer-corner/php/using-php.ini-directives/php-maximum-upload-file-size#:~:text=By%20default%2C%20the%20maximum%20upload,the%20upload_max_filesize%20and%20post_max_size%20directives.

Maybe thats the issue?

i just tried the App with that example PHP-Script on two different Server and with nearly every image i have in Homey available.
The result is always the same. The PHP-Script gets called but no image is send. The Log says “Error: No Image attached”.

Any suggestions whats going wrong?

Hmm. Strange. Just tried to make sure and my camera motion image are uploaded to my server without a problem. Im running it on my webhost with PHP 7.4 no special configurations or anything. Running the latest Homey version.

This is straight from my PHP file. Im

<?php

ini_set("log_errors", 1);
ini_set("error_log", "sendImage-error.log");

$id = uniqid();
$file = 'sendImage-log.txt';
file_put_contents($file, "\n" . date("h:i:sa") . " (" . $id . ") " . "-> Start Receive", FILE_APPEND | LOCK_EX);

if (isset($_FILES['image'])) {
    $errors = array();

    $file_size = $_FILES['image']['size'];
    $file_tmp = $_FILES['image']['tmp_name'];
    $file_type = $_FILES['image']['type'];
    $file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));

    $file_name = time() . "-" . $id . "." . $file_ext;

    $extensions = array("jpeg", "jpg", "png");

    if (in_array($file_ext, $extensions) === false) {
        $errors[] = "extension not allowed, please choose a JPEG or PNG file.";
    }
    if (empty($errors) == true) {
        move_uploaded_file($file_tmp, "images/" . $file_name);
        file_put_contents($file, "\n" . date("h:i:sa") . " (" . $id . ") " . "-> Success: File Uploaded: " . $file_name, FILE_APPEND | LOCK_EX);
        echo "Success";
    } else {
        file_put_contents($file, "\n" . date("h:i:sa") . " (" . $id . ") " . "-> Error: " . $errors, FILE_APPEND | LOCK_EX);
        echo "Error";
    }
} else {
    file_put_contents($file, "\n" . date("h:i:sa") . " (" . $id . ") " . "-> Error: No Image attached", FILE_APPEND | LOCK_EX);
    echo "Error";
}

file_put_contents($file, "\n" . date("h:i:sa") . " (" . $id . ") " . "-> End Receive", FILE_APPEND | LOCK_EX);

Maybe your files are too big? You can add the check mentioned above.

It seems that the problem is a misconfiguration of my server. I could not realy find out whats the problem
Anyway i just switch to a different server and now everything is working fine.
Thank you for your support.

Sweet

Hello and thank you for making this app.
I am using Image grabber to get snap from camera:

And Image poster to send to my server.
It pushes the snapshot sucsessfully to my phone.

But I am getting this error:

10:11:59am (6223295f4169e) -> Start Receive
10:11:59am (6223295f4169e) -> Error: No Image attached
10:11:59am (6223295f4169e) -> End Receive

This is the flow:

On the server end I have put sendImage.php from you in folder:
/Ringeklokke
and made subfolder
/images

This is done on a synology server under WEB/ section.
It writes the log file, but as mentioned above an error that image is not attached.