Develop an open() method within the IBucket interface that returns a file-like object, mimicking the functionality of Python's built-in open() function for interacting with objects in a bucket-based storage system.
Functional Requirements:
- Object Access: The method must accept a parameter that uniquely identifies the object within the bucket (e.g., object key or path).
- Modes: Implement support for both read ('r', 'rb') and write ('w', 'wb') modes.
- File-Like Object: The returned object must implement the following methods, mirroring Python's file object:
- Read Mode:
read(), readline(), readlines(), seek(), tell(), close().
- Write Mode:
write(), flush(), close();
seek() is not supported in write mode.
- Binary and Text Modes: Support both binary ('b') and text modes, handling encoding/decoding as necessary.
- Buffered Operations: Implement buffered read/write operations for efficiency, utilizing flush() to commit writes.
- Error Handling: Implement appropriate error handling for scenarios such as:
- Object not found.
- Insufficient permissions.
- Invalid mode.
- Connection errors.
Acceptance Criteria:
- The
open() method must return a file-like object that behaves consistently with Python's built-in open() for the supported modes.
- Read operations must accurately retrieve object content.
- Write operations must correctly persist data to the bucket.
- Binary and text modes must function as expected.
- Buffered operations and
flush() must operate correctly.
- Appropriate exceptions must be raised for error conditions.
Develop an
open()method within the IBucket interface that returns a file-like object, mimicking the functionality of Python's built-inopen()function for interacting with objects in a bucket-based storage system.Functional Requirements:
read(), readline(), readlines(), seek(), tell(), close().write(), flush(), close();seek()is not supported in write mode.Acceptance Criteria:
open()method must return a file-like object that behaves consistently with Python's built-inopen()for the supported modes.flush()must operate correctly.