Hi Team - We are trying to save a file in some sub...
# prefect-community
c
Hi Team - We are trying to save a file in some sub-folders in the bucket we specified. However, the file is not saved in S3 sub-folders (specified in the base path), but in the bucket
Copy code
csv_file = await s3_bucket_block.write_path(path=output_file, content=bytes_to_write)
k
it's because the path is a WindowsPath, which has
\
instead of
/
.
c
What should I do differently here?
Copy code
s3_block = S3.load("sra-allocations")
s3_base_path = f'Allocations/Fidelity/{date.today().year}'
s3_bucket_block = S3Bucket(
    bucket_name=s3_block.bucket_path,
    aws_credentials=aws_credentials,
    basepath=f"{s3_base_path}"
)
Forward slash before Allocations? <-- This didn't work.
Is this due to debugging the code on my Windows OS?
Would the behavior be different if I ran the flow via ECS Task and Docker container?
k
I believe so.
write_path()
calls
_resolve_path()
, which converts your path string into a
Path
object. On Windows, I think this'll be a
WindowsPath
https://github.com/PrefectHQ/prefect-aws/blob/main/prefect_aws/s3.py#L377
c
Thanks Kevin. I'll give that a shot. I was just debugging the code and the outcome wasn't expected. Thanks for clearing that up.
@Kevin Grismore It worked, thanks for your help.
🙌 1