diff --git a/mdataToCoscine.ipynb b/mdataToCoscine.ipynb
index 00580f9..6db22c4 100644
--- a/mdataToCoscine.ipynb
+++ b/mdataToCoscine.ipynb
@@ -1568,44 +1568,17 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "here_is_a_different_name.txt: 0%| | 0.00/222 [00:00, ?B/s]"
- ]
- },
- {
- "ename": "RequestRejected",
- "evalue": "Coscine rejected the request sent by the Coscine Python SDK with the following error message: {\"data\":{\"type\":\"https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8\",\"title\":\"Conflict\",\"status\":409,\"detail\":\"The blob with the key: \\u0022here_is_a_different_name.txt\\u0022 already exists and can\\u0027t be created. Use update instead.\",\"instance\":\"/api/v2/projects/41ea010a-92e2-4caf-8c28-bde8c96ff226/resources/67de7c6d-fdac-4ba9-91be-be4fc3c3f6b7/blobs/here_is_a_different_name.txt\",\"httpMethod\":\"POST\"},\"statusCode\":409,\"isSuccess\":false,\"traceId\":\"0HMVBP8G01VVV:0000000A\",\"pagination\":null,\"categories\":null}.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mHTTPError\u001b[0m Traceback (most recent call last)",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/client.py:420\u001b[0m, in \u001b[0;36mApiClient.send_request\u001b[0;34m(self, request, stream)\u001b[0m\n\u001b[1;32m 419\u001b[0m logger\u001b[39m.\u001b[39mdebug(response\u001b[39m.\u001b[39mcontent\u001b[39m.\u001b[39mdecode(\u001b[39m\"\u001b[39m\u001b[39mutf-8\u001b[39m\u001b[39m\"\u001b[39m))\n\u001b[0;32m--> 420\u001b[0m response\u001b[39m.\u001b[39;49mraise_for_status()\n\u001b[1;32m 421\u001b[0m \u001b[39mreturn\u001b[39;00m ApiResponse(\u001b[39mself\u001b[39m, request, response)\n",
- "File \u001b[0;32m~/.local/lib/python3.10/site-packages/requests/models.py:1021\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1020\u001b[0m \u001b[39mif\u001b[39;00m http_error_msg:\n\u001b[0;32m-> 1021\u001b[0m \u001b[39mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m)\n",
- "\u001b[0;31mHTTPError\u001b[0m: 409 Client Error: Conflict for url: https://coscine.rwth-aachen.de/coscine/api/v2/projects/41ea010a-92e2-4caf-8c28-bde8c96ff226/resources/67de7c6d-fdac-4ba9-91be-be4fc3c3f6b7/blobs/here_is_a_different_name.txt",
- "\nThe above exception was the direct cause of the following exception:\n",
- "\u001b[0;31mRequestRejected\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m/workspaces/MetadataTransferRDMII/mdataToCoscine.ipynb Cell 49\u001b[0m line \u001b[0;36m4\n\u001b[1;32m 1\u001b[0m local_file_name \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mcat_test_file.txt\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 2\u001b[0m coscine_file_name \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mhere_is_a_different_name.txt\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m----> 4\u001b[0m resource\u001b[39m.\u001b[39;49mupload(coscine_file_name, local_file_name, metadata)\n",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/resource.py:613\u001b[0m, in \u001b[0;36mResource.upload\u001b[0;34m(self, path, handle, metadata, progress)\u001b[0m\n\u001b[1;32m 611\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_upload_blob_s3(path, handle)\n\u001b[1;32m 612\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 613\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_upload_blob(path, handle, progress)\n",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/resource.py:698\u001b[0m, in \u001b[0;36mResource._upload_blob\u001b[0;34m(self, path, handle, progress)\u001b[0m\n\u001b[1;32m 692\u001b[0m monitor \u001b[39m=\u001b[39m MultipartEncoderMonitor(\n\u001b[1;32m 693\u001b[0m encoder,\n\u001b[1;32m 694\u001b[0m \u001b[39mlambda\u001b[39;00m mon:\n\u001b[1;32m 695\u001b[0m progress_callback(progress_bar, mon\u001b[39m.\u001b[39mbytes_read, progress)\n\u001b[1;32m 696\u001b[0m )\n\u001b[1;32m 697\u001b[0m headers \u001b[39m=\u001b[39m {\u001b[39m\"\u001b[39m\u001b[39mContent-Type\u001b[39m\u001b[39m\"\u001b[39m: monitor\u001b[39m.\u001b[39mcontent_type}\n\u001b[0;32m--> 698\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mclient\u001b[39m.\u001b[39;49mpost(uri, data\u001b[39m=\u001b[39;49mmonitor, headers\u001b[39m=\u001b[39;49mheaders)\n",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/client.py:551\u001b[0m, in \u001b[0;36mApiClient.post\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 539\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mpost\u001b[39m(\u001b[39mself\u001b[39m, \u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m ApiResponse:\n\u001b[1;32m 540\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 541\u001b[0m \u001b[39m Sends a POST request to the Coscine REST API.\u001b[39;00m\n\u001b[1;32m 542\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 549\u001b[0m \u001b[39m Refer to ApiClient.request() for a list of exceptions.\u001b[39;00m\n\u001b[1;32m 550\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 551\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mrequest(\u001b[39m\"\u001b[39;49m\u001b[39mPOST\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/client.py:460\u001b[0m, in \u001b[0;36mApiClient.request\u001b[0;34m(self, method, stream, *args, **kwargs)\u001b[0m\n\u001b[1;32m 433\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 434\u001b[0m \u001b[39mSends a request to the Coscine REST API. This method is used\u001b[39;00m\n\u001b[1;32m 435\u001b[0m \u001b[39minternally. As a user of the ApiClient you should use the methods\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 457\u001b[0m \u001b[39mSee coscine.ApiClient.handle_request_exception\u001b[39;00m\n\u001b[1;32m 458\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 459\u001b[0m request \u001b[39m=\u001b[39m requests\u001b[39m.\u001b[39mRequest(method, \u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[0;32m--> 460\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49msend_request(request, stream)\n",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/client.py:423\u001b[0m, in \u001b[0;36mApiClient.send_request\u001b[0;34m(self, request, stream)\u001b[0m\n\u001b[1;32m 421\u001b[0m \u001b[39mreturn\u001b[39;00m ApiResponse(\u001b[39mself\u001b[39m, request, response)\n\u001b[1;32m 422\u001b[0m \u001b[39mexcept\u001b[39;00m requests\u001b[39m.\u001b[39mexceptions\u001b[39m.\u001b[39mRequestException \u001b[39mas\u001b[39;00m error:\n\u001b[0;32m--> 423\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mhandle_request_exception(error)\n\u001b[1;32m 424\u001b[0m \u001b[39mraise\u001b[39;00m error\n",
- "File \u001b[0;32m~/.python/current/lib/python3.10/site-packages/coscine/client.py:495\u001b[0m, in \u001b[0;36mApiClient.handle_request_exception\u001b[0;34m(exception)\u001b[0m\n\u001b[1;32m 490\u001b[0m \u001b[39mif\u001b[39;00m exception\u001b[39m.\u001b[39mresponse\u001b[39m.\u001b[39mstatus_code \u001b[39m==\u001b[39m \u001b[39m401\u001b[39m:\n\u001b[1;32m 491\u001b[0m \u001b[39mraise\u001b[39;00m AuthenticationError(\n\u001b[1;32m 492\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mInvalid Coscine API token! The token was rejected \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 493\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mby Coscine. Check whether it is expired.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 494\u001b[0m ) \u001b[39mfrom\u001b[39;00m \u001b[39mexception\u001b[39;00m\n\u001b[0;32m--> 495\u001b[0m \u001b[39mraise\u001b[39;00m RequestRejected(\n\u001b[1;32m 496\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mCoscine rejected the request sent by the Coscine Python SDK \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 497\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mwith the following error message: \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 498\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mexception\u001b[39m.\u001b[39mresponse\u001b[39m.\u001b[39mcontent\u001b[39m.\u001b[39mdecode(\u001b[39m'\u001b[39m\u001b[39mutf-8\u001b[39m\u001b[39m'\u001b[39m)\u001b[39m}\u001b[39;00m\u001b[39m.\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 499\u001b[0m ) \u001b[39mfrom\u001b[39;00m \u001b[39mexception\u001b[39;00m\n",
- "\u001b[0;31mRequestRejected\u001b[0m: Coscine rejected the request sent by the Coscine Python SDK with the following error message: {\"data\":{\"type\":\"https://datatracker.ietf.org/doc/html/rfc7231#section-6.5.8\",\"title\":\"Conflict\",\"status\":409,\"detail\":\"The blob with the key: \\u0022here_is_a_different_name.txt\\u0022 already exists and can\\u0027t be created. Use update instead.\",\"instance\":\"/api/v2/projects/41ea010a-92e2-4caf-8c28-bde8c96ff226/resources/67de7c6d-fdac-4ba9-91be-be4fc3c3f6b7/blobs/here_is_a_different_name.txt\",\"httpMethod\":\"POST\"},\"statusCode\":409,\"isSuccess\":false,\"traceId\":\"0HMVBP8G01VVV:0000000A\",\"pagination\":null,\"categories\":null}."
- ]
- }
- ],
+ "outputs": [],
"source": [
"local_file_name = \"cat_test_file.txt\"\n",
"coscine_file_name = \"here_is_a_different_name.txt\"\n",
"\n",
- "resource.upload(coscine_file_name, local_file_name, metadata)"
+ "with open(local_file_name, 'rb') as f:\n",
+ " resource.upload(coscine_file_name, f, metadata)\n",
+ "\n",
+ "# note: overwriting files will only work with Coscine Python SDK version 0.10.3 "
]
},
{
@@ -5878,7 +5851,9 @@
"coscine_file_name = 'Pollen1003.jpg'\n",
"\n",
"with open('data/Pollen1003.jpg', \"rb\") as file_path:\n",
- " resource.upload(coscine_file_name, file_path, metadata)"
+ " resource.upload(coscine_file_name, file_path, metadata)\n",
+ "\n",
+ "# note: overwriting files will only work with Coscine Python SDK version 0.10.3 "
]
}
],