temporary-files

temp files/directories with custom names?

限于喜欢 提交于 2020-01-24 19:53:27
问题 How to create a temporary files/directories with user defined names in python. I am aware of tempfile . However I couldn't see any function with filename as argument. Note: I need this for unit testing the glob(file name pattern matching) functionality on a temporary directory containing temporary files rather than using the actual file system. 回答1: You can use open() with whatever file name you need. e.g. open(name, 'w') Open Or import os import tempfile print 'Building a file name yourself:

How guarantee the file will be deleted after automatically some time? [closed]

。_饼干妹妹 提交于 2020-01-22 15:48:12
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I have to store an image for a few minutes after user upload it until user confirm and i store in database So i'm wondering of creating a temporary file and use it to display preview. But I have to be sure that the file will be deleted after some time if user not interact

Limitations of TEMP directory in Windows?

不羁的心 提交于 2020-01-21 11:32:46
问题 I have an application written in Python that's writing large amounts of data to the %TEMP% folder. Oddly, every once and awhile, it dies, returning IOError: [Errno 28] No space left on device . The drive has plenty of free space, %TEMP% is not its own partition, I'm an administrator, and the system has no quotas. Does Windows artificially put some types of limits on the data in %TEMP% ? If not, any ideas on what could be causing this issue? EDIT : Following discussions below, I clarified the

Session Storing Images for Temporary and retrive and store into model

为君一笑 提交于 2020-01-17 08:41:29
问题 I've been searching for long time of solving the limitation in asp file uploading as the case in my question File Upload: Fail to assign value into File, it still not answered by anybody. At this moment, can i know is there anybody here know how to use session to store an image for temporary, and thereafter retrieve it back to the stream and put it into the model ? 回答1: You could convert the image into a byte array then convert it to a base64 string and save that into the session. Then

How to create a temporary file with portable shell in a secure way?

三世轮回 提交于 2020-01-12 07:33:31
问题 I want to create a temporary file in POSIX shell ( /bin/sh ). I found out that mktemp(1) doens't exist on my AIX box, and according to How portable is mktemp(1)?, it isn't that portable and/or secure anyway. So, what should I use instead ? 回答1: Why not use /dev/random ? It could be neater with perl but od and awk will do, something like: tempfile=XXX-$(od -N4 -tu /dev/random | awk 'NR==1 {print $2} {}') 回答2: You didn't exactly define "secure", but one element of it is probably to clean up

Windows directory that will never contain non-ASCII characters for temp file?

余生长醉 提交于 2020-01-06 14:27:37
问题 Using MinGW 7.3.0 on Windows, Hunspell can't load the dictionary files from locations that have non-ASCII characters because of Windows limitations. I've tried everything[1] and I'm now resorting to copying the file to a path without ASCII characters before giving it to Hunspell. What is a good location to copy it to? [1] Windows requires wchar_t support for std::iostream.open() to work right, which MinGW does not implement std::filesystem can solve this, but only available in GCC 8 Hunspell

Where should my windows app store cache and tempfiles?

六眼飞鱼酱① 提交于 2020-01-06 03:22:15
问题 Where should a windows application store cache data and temporary file data ? I understand that System.Windows.Forms.Application.StartupPath + @"\" + "Cache"; is not a good idea since the program is going to probably be installed in Program Files\MyProgram\ for all users and users may not have access to writing to that folder. 回答1: Use this: System.IO.Path.GetTempPath(); Closely related issue: How to get temporary folder for current user 来源: https://stackoverflow.com/questions/5420234/where

Python Write a JSON temporary file from a dictionary

筅森魡賤 提交于 2020-01-04 04:26:07
问题 I'm working on a python(3.6) project in which I need to write a JSON file from a Python dictionary. Here's my dictionary: {'deployment_name': 'sec_deployment', 'credentials': {'type': 'type1', 'project_id': 'id_001',}, 'project_name': 'Brain', 'project_id': 'brain-183103', 'cluster_name': 'numpy', 'zone_region': 'europe-west1-d', 'services': 'Single', 'configuration': '', 'routing': ''} And I need to write credentials key to a JSON file. Here's how I have tried: tempdir = tempfile.mkdtemp()

php - Create file from string and attach to email

一曲冷凌霜 提交于 2020-01-03 02:01:46
问题 I have an application in which users can send me feedback. When they do this, various data from their system is posted to a php file on my server. The php file then handles that data and sends me an email with that data via mail(). Right now, all of the data is just composed into an HTML email. What I want to do is take some of the posted data, convert them to files, and add them as attachments to the email. I know how to add files as attachments with mail(). I just can't think of a way to

I get an error “could not write block … of temporary file no space left on device …” using postgresql

橙三吉。 提交于 2020-01-01 08:44:11
问题 I'm running a really big query, that insert a lot of rows in table, almost 8 million of rows divide in some smaller querys, but in some moment appear that error : "I get an error "could not write block .... of temporary file no space left on device ..." using postgresql". I don't know if i need to delete temporary files after each query and how I can to do that, or if it is related with another issue. Thank you 回答1: OK. As there are still some facts missing, an attempt to answer to maybe