How to post files to endpoint using collabora online integration

I have managed to get the sample code working for CODE using PHP

It has an endpoint I am using their sample iframe with post request. However this request just posts a simple form call, not really giving a file to read, just a fake text file text gets built in the CODE viewer.

What I do not understand, and I find nothing in the documentation, is how I am supposed to post files into the storage? I have tried working with curl to post stuff to the endpoint, I can wopiPutFile invoked but trying to post information, like a file, or even just simple data nothing really happens.

Is storage just a virtual place you post the file contents, its stays in memory, then with the access_token and id you call it and it can be viewed in the CODE viewer?

Has anyone worked on a custom application where you can post files to the storage, then call those file contents to view in the iframe CODE viewer? My scenarios is an app has files, I want to send those files to storage so I can call them to open in the online collabora. I am not understanding something here…

The collabora-online-sdk-example is a repository that hosts multiple WOPIHost applications written in different frameworks. It mimics a backend system, and whatever you send to the example application will return the same when you post information from Collabora.

There is no storage mechanism in the Examples of the WOPI Host Apps. You have to integrate a backend solution to keep it stored, for example, Paperless-ngx for storage.

Happy Hacking

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=“

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