temporary-files

Remove old temporary files when user is logged out

我是研究僧i 提交于 2021-02-08 02:59:24
问题 I have a view that takes logged in user input then runs a function to produce a report. The result is returned in an HTML page. I render the report to PDF as well. I create a PDF with the content from my function and save it in some folder on the server. I don't want to have my server filled with files from every run, so I create a temporary folder (in tmpfs) for each user when they log in and save the path in their session, which is not permanent. session['temp_path'] = '/dev/shm/<random

How do I create a named temporary file on windows in Python?

痞子三分冷 提交于 2021-02-07 05:20:52
问题 I've got a Python program that needs to create a named temporary file which will be opened and closed a couple times over the course of the program, and should be deleted when the program exits. Unfortunately, none of the options in tempfile seem to work: TemporaryFile doesn't have a visible name NamedTemporaryFile creates a file-like object. I just need a filename. I've tried closing the object it returns (after setting delete = False ) but I get stream errors when I try to open the file

Create a “directory” in memory?

走远了吗. 提交于 2021-02-06 11:24:39
问题 I'm working in c#, and looking for a way to create a path to a directory that will map to an IO.Stream instead of to the actual file system. I want to be able to "save" files to that path, manipulate the content or file names, and then save them from that path to a regular file in the file system. I know I can use a temporary file, but I would rather use the memory for both security and performance. This kind of thing exists, according to this answer, in Java , using the FileSystemProvider

Create a “directory” in memory?

为君一笑 提交于 2021-02-06 11:20:27
问题 I'm working in c#, and looking for a way to create a path to a directory that will map to an IO.Stream instead of to the actual file system. I want to be able to "save" files to that path, manipulate the content or file names, and then save them from that path to a regular file in the file system. I know I can use a temporary file, but I would rather use the memory for both security and performance. This kind of thing exists, according to this answer, in Java , using the FileSystemProvider

How to use tempfile.NamedTemporaryFile()?

夙愿已清 提交于 2021-02-06 09:36:05
问题 I'm working on a Python script that needs to create about 50 distinct temporary files, which are all appended frequently during the course of the script and merged at the end. I'm sure that the tempfile module can do what I need, but I haven't been able to figure out how from reading the documentation. I want to use temporary files--as opposed to variables--to conserve system memory, as these data chunks grow large as the script processes tens of thousands of other files. The following chunk

Reading data just written to a temp file

两盒软妹~` 提交于 2021-02-05 12:27:04
问题 In Go, I am trying to write data to a temp file that I then turn around and read but have not been successful. Below is a stripped down test program. I have verified that the data are being written to the file by inspecting the temporary file. So, at least I know that data are making it into the file. I just am then unable to read it out. Thank you for your help in advance package main import ( "bufio" "fmt" "io/ioutil" "log" "os" "path/filepath" ) func main() { tmpFile, err := ioutil

Reading data just written to a temp file

拜拜、爱过 提交于 2021-02-05 12:23:59
问题 In Go, I am trying to write data to a temp file that I then turn around and read but have not been successful. Below is a stripped down test program. I have verified that the data are being written to the file by inspecting the temporary file. So, at least I know that data are making it into the file. I just am then unable to read it out. Thank you for your help in advance package main import ( "bufio" "fmt" "io/ioutil" "log" "os" "path/filepath" ) func main() { tmpFile, err := ioutil

How does boost::filesystem::unique_path() resolve the need in mkstemp analogue in C++?

倖福魔咒の 提交于 2021-01-28 05:42:13
问题 An old feature request for Boost was requesting a feature similar to mkstemp POSIX function to be available in Boost.Filesystem. The issue is long closed as fixed, with the comment The unique_path() function in Version 3 addresses the problem. But I fail to see how unique_path resolves the problem. It's basically the same as tmpnam: after the name has been generated and before actual file is created, another program may have created its file with the same name. So how is it supposed to

Create temporary file in Python that will be deleted automatically after sometime

只谈情不闲聊 提交于 2021-01-04 02:31:24
问题 Is it possible to create temporary files in python that will be deleted after some time? I checked tempfile library which generates temporary files and directories. tempfile.TemporaryFile : This function creates tempfile which will be destroyed as soon as closed. tempfile.NamedTemporaryFile: This function accepts a parameter delete . If delete is given the value false while calling the function the file will not be deleted on close. What I need is a temp file which I should be able to read

std::tmpfile() not picking TMPDIR location

落花浮王杯 提交于 2020-12-13 19:17:25
问题 I am using std::tmpfile() to create temporary files, but I want to use the location other than /tmp. I am exporting $TMPDIR to point to the new location, but std::tmpfile() doesn't pick the new location. How to create temporary files with std::tmpfile() in a folder other than /tmp? 回答1: A quick test program #include <stdio.h> #include <stdlib.h> #include <cstdlib> #include <iostream> int main() { const char* tf = std::tmpnam(nullptr); std::cout << "tmpfile: " << tf << '\n'; return 0; } and an