95 lines
2.3 KiB
Plaintext
95 lines
2.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"*this notebook works in any Sandbox environments* "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Sharing files on the Sandbox Platform\n",
|
|
"### Using Share UI\n",
|
|
"\n",
|
|
"for non technical users an interactive webservice is provided. [ShareUI](https://share.sandbox.iuk.hdm-stuttgart.de/admin). \n",
|
|
"\n",
|
|
"![ShareUI](https://gist.github.com/assets/634470/f90a0c03-8834-4685-95ca-a73e98cabc2f)\n",
|
|
"\n",
|
|
"### Example CLI Share (Headless) File Upload\n",
|
|
"The following example provides a code snippet for sharing a file via cli share. The CLI Endpoint is only avaiable from the Sandbox.\n",
|
|
"#### Using Python"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"uploading file\n",
|
|
"<Response [403]> Forbidden\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import requests\n",
|
|
"\n",
|
|
"myurl = 'https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload'\n",
|
|
"\n",
|
|
"print(\"uploading file\")\n",
|
|
"\n",
|
|
"files = {\n",
|
|
" 'fileUpload':('README.md', open('README.md', 'rb'),'application/octet-stream')\n",
|
|
"}\n",
|
|
"\n",
|
|
"response = requests.post(myurl, files=files)\n",
|
|
"print(response,response.text)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"#### Using Curl\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"``` curl -F fileUpload=@doc.zip https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload ```"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"#### Response\n",
|
|
"\n",
|
|
"The respone of both requests includes the public available download link and the expiration date.\n",
|
|
"\n",
|
|
"\n",
|
|
"``` \n",
|
|
" { \"PublicUrl\":\"https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload/14e4d841-4023-4960-b326-1a117e858fad/README.md\",\n",
|
|
" \"Size\":93,\n",
|
|
" \"Expiration\":\"2024-10-11T00:00:00Z\" }\n",
|
|
" ``` \n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"language_info": {
|
|
"name": "python"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|