Splitting a string takes an arg which is the number of times to split, not the resulting number of elements expected. So string.split("/", 2) fails when the object is in a sub-prefix of the bucket (resultant split is ["bucket", "first_prefix", "other/prefixes"]). It only works if the object is directly in the bucket root.
string.split("/", 1) does what we want and gives ["bucket", "first_prefix/other/prefixes"]
Splitting a string takes an arg which is the number of times to split, not the resulting number of elements expected. So
string.split("/", 2)
fails when the object is in a sub-prefix of the bucket (resultant split is["bucket", "first_prefix", "other/prefixes"]
). It only works if the object is directly in the bucket root.string.split("/", 1)
does what we want and gives["bucket", "first_prefix/other/prefixes"]