Amazon s3 从MYSQL下载转储文件时,Python只读文件系统错误与S3和Lambda有关

Amazon s3 从MYSQL下载转储文件时,Python只读文件系统错误与S3和Lambda有关,amazon-s3,aws-lambda,python-3.6,Amazon S3,Aws Lambda,Python 3.6,我有以下代码用于从mysql运行查询 dump_query=/media/+"/mysql -u"+user+" -p'"+passwd+"' -h"+host+" "+name+" -e '"+query+"' | sed 's/\t/,/g' > "+filepath+"test.csv" proc = subprocess.Popen(dump_query, shell=True) proc.wait() fs = FileSyste

我有以下代码用于从mysql运行查询

        dump_query=/media/+"/mysql -u"+user+" -p'"+passwd+"' -h"+host+" "+name+" -e '"+query+"' | sed 's/\t/,/g' > "+filepath+"test.csv"
 proc = subprocess.Popen(dump_query, shell=True)
        proc.wait()
        fs = FileSystemStorage(filepath)            
        with fs.open('test.csv') as record:
            if os.path.getsize(str(record)) == 0:
                messages.warning(request,"No Data available to download")
                if nexturl is not None:
                    return redirect(nexturl)
                else:
                    return redirect('admin_reports:status_index')
            response = HttpResponse(record, content_type='application/csv')
            response['Content-Disposition'] = 'filename="'+filename+'.csv"'             
            return response
当我试图从lambda处执行此操作时,我得到以下错误。 我对文件夹和csv文件授予了完全权限

 /bin/sh: /var/task/media/downloads/test.csv: Read-only file system

我相信在Lambda上,您只能在
/tmp
目录中编写文件。 试着调整你的代码来做到这一点,它应该会起作用