Open mgsloan opened 6 years ago
Ah, I see now that the docs mention it
Name of the object. For information about how to URL encode object names to be path safe, see Encoding URI Path Parts.
Shouldn't the API handle this for you? Can supply the current thing as a more raw API. #
I just ran into this, and was about to open an issue. The docs on Encoding URI Path Parts say
Note that encoding is typically handled for you by client libraries, so you can pass the raw object name to them.
Yeah, I think the escaping ought to be handled by the library. FWIW, here's the function I wrote for doing the escaping, back when I encountered this issue:
import Data.Text (Text)
import Data.Text.Encoding (encodeUtf8, decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)
import qualified Network.HTTP.Types as HTTP
urlEncodeKey :: Text -> Text
urlEncodeKey
= decodeUtf8With lenientDecode
. HTTP.urlEncode False
. encodeUtf8
To use it, Network.Google.Storage.objectsGet bucket (urlEncodeKey key)
. It should be possible to write a more efficient version that doesn't convert to ByteString and back, but eh
Here is a repro:
Put it in a file called
gogol-bug.hs
. Set thebucket
variable to a bucket in your account. Then,chmod u+x gogol-bug.hs
. Run./gogol-bug.hs
. Get this as output:In other words, uploading an object with a slash in the key works, but downloading fails. Specifically, note the path of the request,
/storage/v1/b/a-bucket/o/gogol-bug:a-key/with-slashes
. The google docs specify that path parts must be url encoded - https://cloud.google.com/storage/docs/json_api/#encoding . However, it appears that they are being substituted verbatim.Is this a gotcha with servant's
Capture
forText
?