#C227. Simulated S3 File Downloader

    ID: 45567 Type: Default 1000ms 256MiB

Simulated S3 File Downloader

Simulated S3 File Downloader

You are tasked with simulating a simplified Amazon S3 file download operation.

Given three input strings, representing the bucket name, the file key, and a local path, your program should output a message indicating the result of the simulated download. The simulation follows these rules:

  • If the bucket name is exactly valid_bucket and the file key is exactly valid_key and the local path is not nocredentials, then the file download is successful. Output: Download successful.
  • If the local path is exactly nocredentials, then simulate a credentials error. Output: Credentials not available.
  • If the file key is exactly invalid_key, then simulate that the file does not exist. Output: The file does not exist.
  • If the bucket name is exactly invalid_bucket, then simulate that the bucket does not exist. Output: The bucket does not exist.
  • For all other cases, output: An error occurred.

All input will be provided via standard input (stdin) and the output should be written to standard output (stdout).

Note: The input will consist of three space-separated strings on a single line, in the order of bucket name, file key, and local path.

inputFormat

The input consists of a single line with three space-separated strings:

  1. bucket_name (a string)
  2. file_key (a string)
  3. local_path (a string)

For example: valid_bucket valid_key local_path

outputFormat

Output a single line message as per the simulation rules. The message should be exactly one of the following:

  • Download successful.
  • Credentials not available.
  • The file does not exist.
  • The bucket does not exist.
  • An error occurred.
## sample
valid_bucket valid_key local_path
Download successful.