api/file usage
Hi,
I need to add an image to the email messages being sent. i'm able to retrieve all the information correctly but it appears the encrypted file/filepath are incorrect vs when i inspect the image in the table, not sure if i missed something in order to grab the photo.
Code to get the photo associated with the user:
$currentUser = 12345;
$MyPhotoKey = _getUserInfo("User_Photo", $currentUser);
$MyPhoto = ClientUrl("CurrentHost()./dams/api/file/tbl_sys_membership/User_Photo/".$currentUser);
$MyPhoto = json_decode($MyPhoto, true);
$MyPhoto = $MyPhoto['User_Photo'][$MyPhotoKey];
This translates to:
http://localhost/dams/api/file/tbl_sys_membership/eyJpdiI6Ink...
vs this when i inspect the image, on the app form where this image is, this is the href:
http://localhost/dams/api/file/tbl_sys_membership/eyJpdiI6Ijk...?session=eyJpdiI6IlZ...=&csrf_name=csrf66e45f327e4a6&csrf_value=QCVF...
notice the encrypted path is different.
also noticed that in Fileviewer.php when when $fn is decrypted, in my function $fn is still some encrypted data, but when i run the inspected url, the $fn displays the readable correct path of the image
looks like my code is missingthe session object, is there a method to obtain this?
to test, i tried this, but it returns nothing: (sessionid is empty as well)
$sessionId = session_id();
$sessionQry = "session=" . Encrypt($sessionId) . "&" . $GLOBALS["TokenNameKey"] . "=" . $GLOBALS["TokenName"] . "&" . $GLOBALS["TokenValueKey"] . "=" . $GLOBALS["TokenValue"];
this is a custom file, with following items added:
<?php
namespace PHPMaker2024\dams;
use PHPMaker2024\dams\{UserProfile, Language, AdvancedSecurity, Timer, HttpErrorHandler, RouteAttributes, SessionHandler};
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Container\ContainerInterface;
use DI\Container as Container;
use DI\ContainerBuilder;
use Slim\Factory\AppFactory;
use Slim\Factory\ServerRequestCreatorFactory;
use Slim\Exception\HttpInternalServerErrorException;
use Middlewares\Whoops;
use Dflydev\DotAccessData\Data;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Connection;
require_once "../vendor/autoload.php";
// Require files
require_once "../src/constants.php";
require_once "../src/config.php";
require_once "../src/phpfn.php";
$ConfigData = new Data($CONFIG); // Ensure that $ConfigData is accessible by Global Codes
require_once "../src/userfn.php";
?>
as an additional note, this script will be run outside the scope of the application via command line and cron, so not sure how session id's or lack of will impact the use of the file api
thanks