Skip to content

Commit 97b145e

Browse files
authored
Fix temporary file issue in s3 (#1526)
* Fix temporary file issue Signed-off-by: Yong Tang <[email protected]> * Add additional comment for reason of passing nullptr. Signed-off-by: Yong Tang <[email protected]>
1 parent af0a2d4 commit 97b145e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tensorflow_io/core/filesystems/s3/s3_filesystem.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,18 @@ typedef struct S3File {
355355
s3_client(s3_client),
356356
transfer_manager(transfer_manager),
357357
outfile(Aws::MakeShared<Aws::Utils::TempFile>(
358-
kS3FileSystemAllocationTag, nullptr, "_s3_filesystem_XXXXXX",
358+
kS3FileSystemAllocationTag,
359+
#if defined(_MSC_VER)
360+
// On Windows, `Aws::FileSystem::CreateTempFilePath()` return
361+
// `C:\Users\username\AppData\Local\Temp\`. Adding template will
362+
// cause an error.
363+
nullptr,
364+
#else
365+
"/tmp/_s3_filesystem_XXXXXX",
366+
#endif
359367
std::ios_base::binary | std::ios_base::trunc | std::ios_base::in |
360-
std::ios_base::out)) {}
368+
std::ios_base::out)) {
369+
}
361370
} S3File;
362371

363372
void Cleanup(TF_WritableFile* file) {

0 commit comments

Comments
 (0)