Comments (2)
Up-to-date Acceptance Criteria
Authorised DELETE request to: http://172.28.129.160:8888/deletefile/
With body of form {"bucket": "<bucket-name>", "file": "<file-path-and-name>"}.
Eg: {"bucket": "ditto-anything-i-want", "file": "/2test2/33testing/444testing/555testing/test.txt"}
Should return a warning message if the bucket or the file does not exist at the S3 end
Otherwise, deletes the file and returns a message confirming the deletion
Testing
Note that as part of #71 status and status code errors will be fixed. ✔️
Works for the happy path and if the bucket or file does not exist at the S3 end ✔️
❌ Problem caused when a file path is given that goes outside the bucket - eg {"bucket": "ditto-anything-i-want", "file": ".."}. Also applies when "file": "" is given
This causes a 500 Internal Server Error
This actually happens for all API calls that require a file or directory
2018-11-30 09:47:57,514 ditto-web-api DEBUG Called delete-file handler
DEBUG:ditto-web-api:Called delete-file handler
2018-11-30 09:47:57,514 ditto-web-api DEBUG About to check for warning to do with bucket name ditto-anything-i-want
DEBUG:ditto-web-api:About to check for warning to do with bucket name ditto-anything-i-want
2018-11-30 09:47:57,517 ditto-web-api DEBUG Bucket "ditto-anything-i-want" does exist
DEBUG:ditto-web-api:Bucket "ditto-anything-i-want" does exist
2018-11-30 09:47:57,517 ditto-web-api DEBUG No bucket related warnings found
DEBUG:ditto-web-api:No bucket related warnings found
ERROR:tornado.application:Uncaught exception DELETE /deletefile/ (172.28.129.1)
HTTPServerRequest(protocol='http', host='172.28.129.160:8888', method='DELETE', uri='/deletefile/', version='HTTP/1.1', remote_ip='172.28.129.1')
Traceback (most recent call last):
File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado/web.py", line 1592, in _execute
result = yield result
File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado_json/schema.py", line 160, in_wrapper
output = rh_method(self, *args, **kwargs)
File "/home/vagrant/ditto_web_api/DittoWebApi/src/handlers/delete_file.py", line 25, in delete
result = self._data_replication_service.try_delete_file(bucket_name, file_rel_path)
File "/home/vagrant/ditto_web_api/DittoWebApi/src/services/data_replication/data_replication_service.py", line 92, in try_delete_file
if not self._external_data_service.does_object_exist(bucket_name, file_rel_path):
File "/home/vagrant/ditto_web_api/DittoWebApi/src/services/external/external_data_service.py", line 79, indoes_object_exist
key = bucket.get_key(file_name)
File "/home/vagrant/ditto_web_api/DittoWebApi/src/services/external/storage_adapters/boto_bucket.py", line13, in get_key
key = self._bucket.get_key(*args, **kwargs)
File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/boto/s3/bucket.py", line 193, in get_key
key, resp = self._get_key_internal(key_name, headers, query_args_l)
File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/boto/s3/bucket.py", line 232, in _get_key_internal
response.status, response.reason, '')
boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request
ERROR:tornado.access:500 DELETE /deletefile/ (172.28.129.1) 61.91ms
from ditto.
Problem caused by attempting to delete a file outside of the root directory has been resolved. This now returns a 403 Forbidden error instead of the previous 500 error
from ditto.
Related Issues (20)
- Web app can make buckets HOT 2
- Web app can retrieve objects
- Investigate S3 bucket locations HOT 3
- Make bucket name part of URL
- Catching S3 bucket error
- Bug in copydir
- Attempting to access non-existant bucket causes Internal Server Error HOT 1
- API is overly fussy HOT 1
- Better handling of errors when files are unreadable
- Adding "user" to POST data
- Web service transfers a single file to S3 interface
- Creating a bucket is purely an admin method HOT 1
- Web service returns list of all ditto buckets
- Web service reports usage by user
- Return failed status and code 400 for unsuccessful requests HOT 2
- BucketConfigService to link each bucket to a root directory and to user group(s) HOT 1
- Implement bucket creation in bucket settings service HOT 1
- Test performance uploading large file to ECHO
- Remove server from content header
- LICENSE.md
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ditto.