-- |
-- Upload the files that are in the processing dir, and move to archive when done.
--
uploadReady :: IncomingDir -> Region -> UploadAccess -> EitherT AmbiataError IO [ArchivedFile]
uploadReady dir r (UploadAccess (TemporaryAccess (TemporaryCreds k s sess) a)) = do
  env' <- setDebugging <$> getDebugging <*> newEnvFromCreds r k s (Just sess)
  let
    env = configure (over serviceRetry (set retryAttempts 10 . set exponentBase 0.6) s3) env'
  bimapEitherT AmbiataAWSUploadError id $ runAWS env
    . local (configureRetries 10)
    $ processReady dir a
uploadReady :: IncomingDir -> Region -> UploadAccess -> EitherT AmbiataError IO [ArchivedFile]
uploadReady dir r (UploadAccess (TemporaryAccess (TemporaryCreds k s sess) a)) = do
  env' <- setDebugging <$> getDebugging <*> newEnvFromCreds r k s (Just sess)
  let
    env = configure (over serviceRetry (set retryAttempts 10 . set exponentBase 0.6) s3) env'
  bimapEitherT AmbiataAWSUploadError id $ runAWS env
    . local (configureRetries 10)
    $ processReady dir a
uploadReady dir r (UploadAccess (TemporaryAccess (TemporaryCreds k s sess) a)) = do
  env' <- setDebugging <$> getDebugging <*> newEnvFromCreds r k s (Just sess)
  let
    env = configure (over serviceRetry (set retryAttempts 10 . set exponentBase 0.6) s3) env'
  bimapEitherT AmbiataAWSUploadError id $ runAWS env
    . local (configureRetries 10)
    $ processReady dir a