Skip to content
Snippets Groups Projects
Commit 61bcf397 authored by Carsten Karbach's avatar Carsten Karbach
Browse files

Add example for uploading files via GCSJARDS API client

parent 9b456acc
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
"require": {
"silex/silex": ">=2.0",
"jards/eventsapiclient": "=3.0",
"jards/gcsjardsapiclient": "=2.0",
"jards/gcsjardsapiclient": "=2.1",
"phpmailer/phpmailer": ">=6.0"
},
"require-dev": {
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "cdf21b69798ca5f38caf3b3006641ccb",
"content-hash": "59a3b1ffcc680df0da87660605b8e38c",
"packages": [
{
"name": "jards/eventsapiclient",
......@@ -57,11 +57,11 @@
},
{
"name": "jards/gcsjardsapiclient",
"version": "v2.0",
"version": "v2.1",
"source": {
"type": "git",
"url": "https://gitlab.version.fz-juelich.de/jards/GCSJARDSAPIClient.git",
"reference": "8cd17ed33e447f6af8adcda2e6bb3269e2587ee8"
"reference": "961a06c2218c7ad462479e72dd89bd200e84ed7c"
},
"require": {
"ext-curl": "*",
......@@ -102,7 +102,7 @@
"sdk",
"swagger"
],
"time": "2018-01-22T12:20:35+00:00"
"time": "2018-02-14T12:04:30+00:00"
},
{
"name": "phpmailer/phpmailer",
......
No preview for this file type
<?php
/*
* Copyright (c) 2018, Forschungszentrum Juelich GmbH, Federal Republic of Germany.
* All rights reserved.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once __DIR__ . '/../vendor/autoload.php';
$conf = parse_ini_file(__DIR__.'/../configs/gcsjardsapi.conf');
$certFile = $conf['CERTFILE'];
$certKey = $conf['CERTKEY'];
$certPassphrase = $conf['CERTPASSPHRASE'];
$baseURL = $conf['BASEURL'];
date_default_timezone_set ( 'Europe/Amsterdam' );
$apiClient = new \jards\gcsjardsapiclient\Swagger\Client\ApiClient ();
$apiClient->getConfig ()->setHost ( $baseURL );
if (! empty ( $certFile )) {
$apiClient->getConfig ()->setCertificate ( $certFile );
}
if (! empty ( $certKey )) {
$apiClient->getConfig ()->setCertificateKey ( $certKey );
}
if (! empty ( $certPassphrase )) {
$apiClient->getConfig ()->setCertificatePassphrase ( $certPassphrase );
}
$gcsjardsAPI = new \jards\gcsjardsapiclient\Swagger\Client\Api\FilesApi( $apiClient );
$appid = 19967;
try {
$fileupload = new \SplFileObject('/path/to/example.pdf');
$result = $gcsjardsAPI->filesAppidFilePost($appid, 'status', $fileupload);
echo "Upload result: ".$result."\n";
} catch ( \jards\gcsjardsapiclient\Swagger\Client\ApiException $e ) {
var_dump($e);
return false;
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment