Download the PHP package dsijak/sharefile without Composer

On this page you can find all versions of the php package dsijak/sharefile. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sharefile

Sharefile

Share files protected with access token.

Before use configure vendor/dsijak/sharefile/project/Etc/config.php.
Setting DS_SF_MODE mode to production will disable browser error log output.

Install

        composer require dsijak/sharefile

Usage

First set directory with files in config.php => DS_SF_FILE_DIR. This
directory should be not accessable via url.

Acquire file item:

        $accessToken = $sharefile->acquireItem('vid.mp4');

File must exist and allowed filetype must be specified in config.php.
acquireItem method will store file, key and keyExpiration data into
sqlite/mariadb database. acquireItem method returns access token or key.
After this, you can send this key/token to whomever you want to have access
to acquired file.

Obtain file item:

        $sharefile->obtainItem('vid.mp4', 'f8b32a778acfaaaa');

This will generate new file with header inside your browser.
obtainItem method must be executed from new route or after redirected.
If key has expired, only text message will be generated.

What is this useful for?

For example, when you are selling digital items. When someone buys your
photography or ebook, you can send them file key. Key will be valid
only for amount of time you specify in the config.php.

For example, you can mail link yoursite.com/obtainItem?filename=vid.mp4&key=f8b32a778acfaaaa Then you can take file and key params:

        $sharefile->obtainItem($filename, $key);

This will generate acquired document or text document with message.

Error messages

Both acquireItem and obtainItem methods accept additional reference
argument to pass back error message.

        $errorMessage = '';
        $accessToken = $sharefile->acquireItem('ebook.pdf', $errorMessage);

        if (!$accessToken)
        {
            error_log($errorMessage);
        }

Short usage example

        use Sharefile\Sharefile;

        $sharefile = new Sharefile();
        $errorMessage = '';
        $accessToken = $sharefile->acquireItem('vid.mp4', $errorMessage);
        if (!$accessToken)
        {
            error_log($errorMessage);
        }

        $sharefile->obtainItem('vid.mp4', $accessToken);
        //renders file

MariaDB Usage

Run this query:

        CREATE DATABASE ds_sharefile; 
        CREATE USER 'ds_sharefile'@'localhost' IDENTIFIED BY 'ds_sharefile';
        GRANT ALL ON ds_sharefile.* TO 'ds_sharefile'@'localhost';
        USE ds_sharefile;

Edit: vendor/dsijak/sharefile/project/Etc/config.php.
Set DS_SF_MODEL_TYPE to mariadb.
Database user/pass are also set there.
To use existing PDO object, pass it to constructor together with database name:

        $sharefile = new Sharefile($pdoObj, 'myDatabaseName');

Advanced methods

These methods returns data/null or true/false.
You can get advanced methods through advanced property:

        $x = $sharefile->advanced->databaseCreatedAt($errorMessage);

Methods:

fileExists($filename, &$eMessage=null)
Checks if file exists.

emptyDatabase(&$eMessage=null)
Removes all aquired items from database.

databaseCreatedAt(&$eMessage=null)
Returns creation date.

generateFileKey($filename, &$eMessage=null)
Generates key for filename and stores everything.

deleteKey($key, &$eMessage=null)
Deletes key, if exists.

getGeneratedFileKeyRecord($filename, $key, &$eMessage=null)
Returns key/filename, if exists.

isKeyValid($filename, $key, &$eMessage=null)
Checks if key/token is valid.

generateBase64ImageFile($filename, &$eMessage=null)
Generates html img element with base64 image. This is ment to be used with images.

generateHeaderFile($filename)
Generates file as HTTP respose.

generateHeaderMessage($message)
Generates text file as HTTP respose with $message.

Have Fun

Developed and tested under 5.4.118-1-manjaro/xfce/docker/portainer


All versions of sharefile with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dsijak/sharefile contains the following files

Loading the files please wait ....