file

Sending file direct from browser to S3 but changing file name

∥☆過路亽.° 提交于 2021-02-07 13:18:35
问题 I am using signed authorized S3 uploads so that users can upload files directly from their browser to S3 bypassing my server. This presently works, but the file name is the same as on the user's machine. I'd like to save it on S3 as a different name. The formdata I post to amazon looks like this: var formData = new FormData(); formData.append('key', targetPath); // e.g. /path/inside/bucket/myFile.mov formData.append('AWSAccessKeyId', s3Auth.AWSAccessKeyId); // aws public key formData.append(

Sending file direct from browser to S3 but changing file name

十年热恋 提交于 2021-02-07 13:17:09
问题 I am using signed authorized S3 uploads so that users can upload files directly from their browser to S3 bypassing my server. This presently works, but the file name is the same as on the user's machine. I'd like to save it on S3 as a different name. The formdata I post to amazon looks like this: var formData = new FormData(); formData.append('key', targetPath); // e.g. /path/inside/bucket/myFile.mov formData.append('AWSAccessKeyId', s3Auth.AWSAccessKeyId); // aws public key formData.append(

Check whether file has been opened already

浪尽此生 提交于 2021-02-07 13:12:09
问题 I am writing a file reading library, and need to check whether a file has been opened so that I can skip the open statement and go directly to a read. How can this be achieved in fortran? 回答1: When one wants to know about connections to external files there is the inquire statement. There are two forms to this: inquire by file; inquire by unit. tom's answer shows inquire by unit. This tests whether unit 3 is connected to any file. One could then go on to ask the name of the connected file

Check whether file has been opened already

Deadly 提交于 2021-02-07 13:10:37
问题 I am writing a file reading library, and need to check whether a file has been opened so that I can skip the open statement and go directly to a read. How can this be achieved in fortran? 回答1: When one wants to know about connections to external files there is the inquire statement. There are two forms to this: inquire by file; inquire by unit. tom's answer shows inquire by unit. This tests whether unit 3 is connected to any file. One could then go on to ask the name of the connected file

Explicit way to close file in Python

﹥>﹥吖頭↗ 提交于 2021-02-07 11:45:11
问题 Please look at the following code: for i in xrange(1,5000): with open(r'test\test%s.txt' % i, 'w') as qq: qq.write('aa'*3000) It seems to be written according to all Python rules; files are closing after using. Seems to. But in fact it seems to recommend(!) system to close file, not to close it explicitly because when I'm looking on Resource monitor it shows a lot of open files . It gives me a lot of problems because in my script I use a lot of files and after a long time I got "Too many open

How to get only files in directory? [duplicate]

佐手、 提交于 2021-02-07 11:18:18
问题 This question already has answers here : How do I list all files of a directory? (21 answers) Closed 7 years ago . I have this code: allFiles = os.listdir(myPath) for module in allFiles: if 'Module' in module: #if the word module is in the filename dirToScreens = os.path.join(myPath, module) allSreens = os.listdir(dirToScreens) Now, all works well, I just need to change the line allSreens = os.listdir(dirToScreens) to get a list of just files, not folders. Therefore, when I use allScreens [ f

How to get only files in directory? [duplicate]

安稳与你 提交于 2021-02-07 11:17:48
问题 This question already has answers here : How do I list all files of a directory? (21 answers) Closed 7 years ago . I have this code: allFiles = os.listdir(myPath) for module in allFiles: if 'Module' in module: #if the word module is in the filename dirToScreens = os.path.join(myPath, module) allSreens = os.listdir(dirToScreens) Now, all works well, I just need to change the line allSreens = os.listdir(dirToScreens) to get a list of just files, not folders. Therefore, when I use allScreens [ f

Python3 list files from particular directory [duplicate]

不想你离开。 提交于 2021-02-07 11:16:43
问题 This question already has answers here : How do I list all files of a directory? (21 answers) Non-recursive os.walk() (4 answers) Directory-tree listing in Python (20 answers) Closed 4 years ago . How to list file names which are only from a particular directory? I don't want file names from sub-directory or anything. 回答1: os.listdir(dir) Also see List files in ONLY the current directory 来源: https://stackoverflow.com/questions/37489280/python3-list-files-from-particular-directory

Python3 list files from particular directory [duplicate]

♀尐吖头ヾ 提交于 2021-02-07 11:15:23
问题 This question already has answers here : How do I list all files of a directory? (21 answers) Non-recursive os.walk() (4 answers) Directory-tree listing in Python (20 answers) Closed 4 years ago . How to list file names which are only from a particular directory? I don't want file names from sub-directory or anything. 回答1: os.listdir(dir) Also see List files in ONLY the current directory 来源: https://stackoverflow.com/questions/37489280/python3-list-files-from-particular-directory

Force file download once a site is visited

六月ゝ 毕业季﹏ 提交于 2021-02-07 10:29:00
问题 I have a simple site example.com and an external file link. I want this scenario to be implemented: Once a user visits example.com, a file from an external link is automatically downloaded. Mind that I don't want a user to click some link, but just an immediate file download once the site is visited. Thus <a href="link/to/file" download>Download</a> is not what I need. Thanks in advance. 回答1: Simply create a link and click on it via js: <script> window.onload = function(){ var a = document