{"id":22213789,"url":"https://github.com/damir-sijakovic/sharefile","last_synced_at":"2026-05-01T16:32:20.960Z","repository":{"id":56972878,"uuid":"374365337","full_name":"damir-sijakovic/sharefile","owner":"damir-sijakovic","description":"Share files protected with access token.","archived":false,"fork":false,"pushed_at":"2021-06-06T13:20:45.000Z","size":4771,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T19:58:43.145Z","etag":null,"topics":["filesharing","php","sqlite"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/damir-sijakovic.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-06T13:18:53.000Z","updated_at":"2021-06-06T13:24:05.000Z","dependencies_parsed_at":"2022-08-21T10:20:10.000Z","dependency_job_id":null,"html_url":"https://github.com/damir-sijakovic/sharefile","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/damir-sijakovic/sharefile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damir-sijakovic%2Fsharefile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damir-sijakovic%2Fsharefile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damir-sijakovic%2Fsharefile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damir-sijakovic%2Fsharefile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damir-sijakovic","download_url":"https://codeload.github.com/damir-sijakovic/sharefile/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damir-sijakovic%2Fsharefile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32505078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filesharing","php","sqlite"],"created_at":"2024-12-02T21:11:17.062Z","updated_at":"2026-05-01T16:32:20.942Z","avatar_url":"https://github.com/damir-sijakovic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sharefile\n\n## Share files protected with access token.\n\nBefore use configure `vendor/dsijak/sharefile/project/Etc/config.php`.   \nSetting `DS_SF_MODE` mode to `production` will disable browser error log output.   \n\n\n### Install\n\n            composer require dsijak/sharefile\n\n### Usage\n\nFirst set directory with files in `config.php =\u003e DS_SF_FILE_DIR`. This    \ndirectory should be not accessable via url.     \n\nAcquire file item:\n\n            $accessToken = $sharefile-\u003eacquireItem('vid.mp4');\n\nFile must exist and allowed filetype must be specified in `config.php`.     \n`acquireItem` method will store file, key and keyExpiration data into     \nsqlite/mariadb database. `acquireItem` method returns access token or key.    \nAfter this, you can send this key/token to whomever you want to have access     \nto acquired file.     \n\nObtain file item:\n \n            $sharefile-\u003eobtainItem('vid.mp4', 'f8b32a778acfaaaa');\n\nThis will generate new file with header inside your browser.     \n`obtainItem` method must be executed from new route or after redirected.     \nIf key has expired, only text message will be generated.    \n\n### What is this useful for?\n\nFor example, when you are selling digital items. When someone buys your     \nphotography or ebook, you can send them file key. Key will be valid    \nonly for amount of time you specify in the `config.php`.   \n\nFor example, you can mail link `yoursite.com/obtainItem?filename=vid.mp4\u0026key=f8b32a778acfaaaa`\nThen you can take file and key params:  \n\n            $sharefile-\u003eobtainItem($filename, $key);\n\nThis will generate acquired document or text document with message.    \n\n### Error messages\n\nBoth `acquireItem` and `obtainItem` methods accept additional reference     \nargument to pass back error message.    \n\n            $errorMessage = '';\n            $accessToken = $sharefile-\u003eacquireItem('ebook.pdf', $errorMessage);\n\n            if (!$accessToken)\n            {\n                error_log($errorMessage);\n            }\n\n### Short usage example \n\n            use Sharefile\\Sharefile;\n            \n            $sharefile = new Sharefile();\n            $errorMessage = '';\n            $accessToken = $sharefile-\u003eacquireItem('vid.mp4', $errorMessage);\n            if (!$accessToken)\n            {\n                error_log($errorMessage);\n            }\n\n            $sharefile-\u003eobtainItem('vid.mp4', $accessToken);\n            //renders file\n\n\n### MariaDB Usage\n\nRun this query:\n\n            CREATE DATABASE ds_sharefile; \n            CREATE USER 'ds_sharefile'@'localhost' IDENTIFIED BY 'ds_sharefile';\n            GRANT ALL ON ds_sharefile.* TO 'ds_sharefile'@'localhost';\n            USE ds_sharefile;\n\nEdit: `vendor/dsijak/sharefile/project/Etc/config.php`.    \nSet `DS_SF_MODEL_TYPE` to `mariadb`.   \nDatabase user/pass are also set there.   \nTo use existing PDO object, pass it to constructor together with database name:  \n\n            $sharefile = new Sharefile($pdoObj, 'myDatabaseName');\n\n### Advanced methods\n\nThese methods returns data/null or true/false.   \nYou can get advanced methods through `advanced` property:\n\n            $x = $sharefile-\u003eadvanced-\u003edatabaseCreatedAt($errorMessage);\n\n#### Methods:\n\n**fileExists($filename, \u0026$eMessage=null)**    \nChecks if file exists.\n  \n**emptyDatabase(\u0026$eMessage=null)**    \nRemoves all aquired items from database.\n  \n**databaseCreatedAt(\u0026$eMessage=null)**   \nReturns creation date.\n   \n**generateFileKey($filename, \u0026$eMessage=null)**     \nGenerates key for filename and stores everything.\n\n**deleteKey($key, \u0026$eMessage=null)**     \nDeletes key, if exists.\n   \n**getGeneratedFileKeyRecord($filename, $key, \u0026$eMessage=null)**    \nReturns key/filename, if exists.\n \n**isKeyValid($filename, $key, \u0026$eMessage=null)**    \nChecks if key/token is valid.\n    \n**generateBase64ImageFile($filename, \u0026$eMessage=null)**   \nGenerates html img element with base64 image. This is ment to be used with images.\n  \n**generateHeaderFile($filename)**       \nGenerates file as HTTP respose.\n\n**generateHeaderMessage($message)**     \nGenerates text file as HTTP respose with $message.\n\n\n### Have Fun\n`Developed and tested under 5.4.118-1-manjaro/xfce/docker/portainer`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamir-sijakovic%2Fsharefile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamir-sijakovic%2Fsharefile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamir-sijakovic%2Fsharefile/lists"}