brendanhay / gogol

A comprehensive Google Services SDK for Haskell.
Other
280 stars 105 forks source link

Help with setting metadata for object upload in Google Cloud Storage #160

Closed iAmMrinal0 closed 3 years ago

iAmMrinal0 commented 3 years ago

This is a minimal snippet that I'm trying to use to upload an object and set its metadata:

  void $ do
    lgr  <- Google.newLogger Google.Debug stdout
    googleEnv <- Google.newEnv <&> (Google.envLogger .~ lgr) . (envScopes .~ storageReadWriteScope)
    runResourceT $
      runGoogle googleEnv $
      upload
      (objectsInsert bkt $
       object'
       & objMetadata._Just.omAddtional.at "foo" ?~ "bar"
       & objName ?~ "test.json") "true"

In the response, the value is Nothing for metadata and just to be sure I verified on the object on GCS and it did not have them set too. Have I missed something in the code or should I do use objects patch to update it somehow?

iAmMrinal0 commented 3 years ago

Used the lenses incorrectly. The correct usage was:

& objMetadata ?~ objectMetadata (HM.singleton "foo" "bar")