From c9f79e641c6906e95095f3e0e505f9bd3f715bc2 Mon Sep 17 00:00:00 2001
From: Tim Burke <tim.burke@gmail.com>
Date: Thu, 5 Mar 2015 15:28:42 -0800
Subject: [PATCH] Mention --segment-size option after 413 response

Previously, it would only output something like

  ClientException: Object PUT failed <url> 413 Request Entity Too Large
  Your request is too large.

... which is misleading as it implies that Swift simply can't handle
large objects.

Change-Id: Icec9e76b2671490c3a2249ec08992950107c6828
---
 swiftclient/shell.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index e579b8fb..c7bb4f80 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -845,6 +845,12 @@ def st_upload(parser, args, output_manager):
                         )
                     else:
                         output_manager.error("%s" % error)
+                        too_large = (isinstance(error, ClientException) and
+                                     error.http_status == 413)
+                        if too_large and options.verbose > 0:
+                            output_manager.error(
+                                "Consider using the --segment-size option "
+                                "to chunk the object")
 
         except SwiftError as e:
             output_manager.error(e.value)