Thank you for your comment. I am pretty aware of the link I shared about the examples in multiple languages.
Unfortunately, this does not help me. My questions are in regard to understanding how I would go by posting file content so that it can be viewed later using the calls. Creating a backend to store files and retrieving them is not my problem. What I am trying to understand is how to read the file from the documentId with wopiCheckFileInfo() and wopiGetFile(), then read the contents of that file and echo it back.
Fortunately, with a lot of messing around, I have managed to fulfill what is requested from wopiCheckFileInfo() and output via wopiGetFile() using static example locations as an APP. ( I do not follow a traditional file storage, my files are all over the place in different environments in the APP )
Anyone would like a raw starting point if you are close to my situation in understanding a custom build:
function wopiCheckFileInfo( $documentId ) {
// test.txt is just a fake text file
// the Size property is the length of the string
// returned in wopiGetFile
/*
$response = [
'BaseFileName' => 'test.txt',
'Size' => 11,
'UserId' => 1,
'UserCanWrite' => true
];
*/
$fileHandle = fopen( $_SERVER['DOCUMENT_ROOT'] . '/admin/clients/files/ÉVALUATION|PHYSIQUE.doc', 'r');
$lines = fread( $fileHandle, filesize( $_SERVER['DOCUMENT_ROOT'] . '/admin/clients/files/ÉVALUATION|PHYSIQUE.doc' ) );
$response = [
'BaseFileName' => $_SERVER['DOCUMENT_ROOT'] . '/admin/clients/files/ÉVALUATION|PHYSIQUE.doc',
'Size' => filesize( $_SERVER['DOCUMENT_ROOT'] . '/admin/clients/files/ÉVALUATION|PHYSIQUE.doc'),
'UserId' => 1,
'UserCanWrite' => true
];
$jsonResponse = json_encode( $response );
echo $jsonResponse;
}
function wopiGetFile( $documentId ) {
// we just return the content of a fake text file
// in a real case you should use the document id
// for retrieving the file from the storage and
// send back the file content as response
$fileHandle = fopen( $_SERVER['DOCUMENT_ROOT'] . '/admin/clients/files/ÉVALUATION|PHYSIQUE.doc', 'r');
$content = fread( $fileHandle, filesize( $_SERVER['DOCUMENT_ROOT'] . '/admin/clients/files/ÉVALUATION|PHYSIQUE.doc' ) );
echo $content;
}
Again, this is a pretty static example just to see if I could get the output to the CODE iframe, and it worked.
Now I am trying to understand the call itself that is submitted with ex. form action=“https://code.domain.ca/browser/bcbca64/cool.html?WOPISrc=https://domain.ca/wopi/files/n363o133finqipyh6akoxtrgmy”
You cannot put just any filename here, from what I can see nothing is accepted but strings and numbers. Anything a uri cannot take as in spacial characters, language accents etc. It makes it difficult to identify the file without renaming it or associating it to a random string.
A way around this will be another happy hacking