From 6fbe57957535363ae79bdde4dd602a6f32c87819 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 9 Sep 2021 18:45:40 +0000 Subject: [PATCH 1/2] Fix temporary file issue Signed-off-by: Yong Tang --- tensorflow_io/core/filesystems/s3/s3_filesystem.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tensorflow_io/core/filesystems/s3/s3_filesystem.cc b/tensorflow_io/core/filesystems/s3/s3_filesystem.cc index 4c748569e..70f853e33 100644 --- a/tensorflow_io/core/filesystems/s3/s3_filesystem.cc +++ b/tensorflow_io/core/filesystems/s3/s3_filesystem.cc @@ -355,9 +355,15 @@ typedef struct S3File { s3_client(s3_client), transfer_manager(transfer_manager), outfile(Aws::MakeShared( - kS3FileSystemAllocationTag, nullptr, "_s3_filesystem_XXXXXX", + kS3FileSystemAllocationTag, +#if defined(_MSC_VER) + nullptr, +#else + "/tmp/_s3_filesystem_XXXXXX", +#endif std::ios_base::binary | std::ios_base::trunc | std::ios_base::in | - std::ios_base::out)) {} + std::ios_base::out)) { + } } S3File; void Cleanup(TF_WritableFile* file) { From 2149fab290126d546b51914073448a45722a7ee7 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 9 Sep 2021 22:55:15 +0000 Subject: [PATCH 2/2] Add additional comment for reason of passing nullptr. Signed-off-by: Yong Tang --- tensorflow_io/core/filesystems/s3/s3_filesystem.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow_io/core/filesystems/s3/s3_filesystem.cc b/tensorflow_io/core/filesystems/s3/s3_filesystem.cc index 70f853e33..f071d8b0f 100644 --- a/tensorflow_io/core/filesystems/s3/s3_filesystem.cc +++ b/tensorflow_io/core/filesystems/s3/s3_filesystem.cc @@ -357,6 +357,9 @@ typedef struct S3File { outfile(Aws::MakeShared( kS3FileSystemAllocationTag, #if defined(_MSC_VER) + // On Windows, `Aws::FileSystem::CreateTempFilePath()` return + // `C:\Users\username\AppData\Local\Temp\`. Adding template will + // cause an error. nullptr, #else "/tmp/_s3_filesystem_XXXXXX",