Topic by Paul Smith
Content
Hi,
I am using getAdminUrl() on an organizations file attachments ($org->FileAttachments[0]->getAdminUrl()) to obtain the URL for a file attachment using connectPHP on the portal.
I am well aware that you must be logged in to connetPHP with username and password of a staff account with necessary access, which I am doing.
Now the problem I have is this....
I can get the URL fine, this is in the form of http://{site}/cgi-bin/{site}.cfg/php/admin/console_util/fa_get.php?p_parms=U61PvF7SXwir...... (i have shortened the p_parms value for sanity reasons ;)
Now if not logged into connect for php with a staff account, I cannot get the URL, so I know the function getAdminUrl() is generating a URL fine using the staff account.
The problem is that this URL that is generated keeps kicking back with Access Denied, This session is no longer valid. One possible cause is that you are logged in on another copy of the program, Whenever I try to navigate to the URL from a browser.
The staff account details are being used elsewhere and this is a generic model that is used in many places so the code is good. The URL generation is working, it's just the URL that is generated (which I can try to hit from a the same browser window, another tab, another browser) just keeps kicking back this access denied.
The docs state to use file_get_contents() in order to grab the file data, but then other comments on the forum suggest the docs are wrong and file_get_contents will not work. This is a security measure to stop you from doing this due to loop issues from the same server. So my question is has anyone else managed to grab file attachments in this way from an organization object or any other object that uses supposed 'private storage' and not the public storage that incidents uses.
I know I can do this from incidents, I even have a cruder chunking method for storing the file in a custom object should I have to, but can I not hit the getAdminUrl generated url to download the attachment from a browser window just by navigating to it?
Is there some console config value or other configuration needed to allow the code at ...........cfg/php/admin/console_util/fa_get.php access to get at teh attachment. I really do think that the issue here is that fa_get.php code needs some kind of session (and yes I have tried appending p_sid on the end of the url to no avail)
any help would be most appreciated.
ta
Paul