在mysql中存储卷曲会话cookie(Storing curl session cookies in mysql)
我想知道是否可以在mysql中存储curl的会话cookie。
curl_setopt($ch, CURLOPT_COOKIEJAR, get_the_cookie()); curl_setopt($ch, CURLOPT_COOKIEFILE, get_the_cookie());
get_the_cookie()返回一个unique-to-user.txt文件路径,但我希望能够将这个cookie存储在mysql而不是文件系统中,如果它可能的话。
I was wondering if it was possible to store a curl's session cookie inside of mysql.
curl_setopt($ch, CURLOPT_COOKIEJAR, get_the_cookie()); curl_setopt($ch, CURLOPT_COOKIEFILE, get_the_cookie());
get_the_cookie() returns a unique-to-user.txt file path, but I want to be able to store this cookie in a mysql instead of the file-system if its even possible.
原文:https://stackoverflow.com/questions/9752857
最满意答案
gsutil
文档的Parallel Composite Uploads部分描述了如何解决这个问题(假设,如警告所指定的那样,crcmod
模块可用的客户端将使用此内容):gsutil -o GSUtil:parallel_composite_upload_threshold=150M cp bigfile gs://your-bucket
从Python安全地做到这一点看起来像这样:
filename='myfile.csv' gs_bucket='my/bucket' parallel_threshold='150M' # minimum size for parallel upload; 0 to disable subprocess.check_call([ 'gsutil', '-o', 'GSUtil:parallel_composite_upload_threshold=%s' % (parallel_threshold,), 'cp', filename, 'gs://%s/%s' % (gs_bucket, filename) ])
请注意,在这里您明确提供了参数向量边界,并且不依赖于shell来为您执行此操作; 这可以防止恶意或错误的文件名执行不需要的操作。
如果您不知道访问此存储桶中的内容的客户端将具有
crcmod
模块,请考虑在上面设置parallel_threshold='0'
,这将禁用此支持。The Parallel Composite Uploads section of the documentation for
gsutil
describes how to resolve this (assuming, as the warning specifies, that this content will be used by clients with thecrcmod
module available):gsutil -o GSUtil:parallel_composite_upload_threshold=150M cp bigfile gs://your-bucket
To do this safely from Python would look like:
filename='myfile.csv' gs_bucket='my/bucket' parallel_threshold='150M' # minimum size for parallel upload; 0 to disable subprocess.check_call([ 'gsutil', '-o', 'GSUtil:parallel_composite_upload_threshold=%s' % (parallel_threshold,), 'cp', filename, 'gs://%s/%s' % (gs_bucket, filename) ])
Note that here you're explicitly providing argument vector boundaries, and not relying on a shell to do this for you; this prevents a malicious or buggy filename from performing undesired operations.
If you don't know that the clients accessing content in this bucket will have the
crcmod
module, consider settingparallel_threshold='0'
above, which will disable this support.
相关问答
更多-
无法导入gsutil(Unable to import gsutil)[2022-11-11]
gsutil仅用于命令行。 如果您想在appengine应用程序中与云存储进行交互,则应使用云存储客户端库: https : //developers.google.com/appengine/docs/java/googlecloudstorageclient/ gsutil is intended to only be used from the command line. If you want to interact with cloud storage from within an appengi ... -
使用Google Drive和gsutil将文件上传到GCS的比较(Comparison of uploading files to GCS using Google Drive vs gsutil)[2022-11-14]
我不确定在后台使用gsutil的GDrive。 有几种优化方法可以用来提高gsutil速度。 首先,您可能会使用perfdiag来启动一个小型诊断测试,这将为您提供可能的概览和可能的速度。 gsutil perfdiag -o test.json gs://其次,您需要了解您的工作量(小/大文件)并确定是否需要区域或多区域存储桶(是的,存在性能差异)tl; dr: “区域桶对于数据处理来说非常棒,因为它们的物理距离相当紧密,并且写入一致性的开销很低。” “另一方面,多 ... -
gsutil cp -I参数应该对此有所帮助。 它允许您读取要从stdin复制的文件列表。 我认为这会奏效: find my-dir/* -newer temp/foo | gsutil -m cp -I gs://my-bucket/ The gsutil cp -I parameter should help with this. It allows you to read the list of files to copy from stdin. I think this would work: f ...
-
该问题不是云存储问题。 文化研究所现在在为其数据库处理后,从云存储中删除文件。 问题解决了。 The issue was not a Cloud Storage issue. The Cultural Institute now deletes files from Cloud Storage after they have been processed for their database. Problem solved.
-
基于gsutil文档 ,假设/tmp/foo.txt实际存在,此语法应该有效。 gsutil cp /tmp/foo.txt gs://my-awesome-bucketmgtest 如果再次收到错误消息,请尝试运行ls /tmp/foo.txt并查看所得到的结果。 编辑:我只是意识到你试图在你的云端而不是本地机器上运行这个命令。 我建议您将GCloud SDK下载到本地计算机上,然后将其推送到上面......这只是简单一些。 或者,您可以从目的地运行它以从笔记本电脑上拉出来,但您需要为您的笔记本电脑提供 ...
-
我应该怎么做这个gsutil“并行复合上传”警告?(What should I do about this gsutil “parallel composite upload” warning?)[2021-08-24]
gsutil文档的Parallel Composite Uploads部分描述了如何解决这个问题(假设,如警告所指定的那样, crcmod模块可用的客户端将使用此内容): gsutil -o GSUtil:parallel_composite_upload_threshold=150M cp bigfile gs://your-bucket 从Python安全地做到这一点看起来像这样: filename='myfile.csv' gs_bucket='my/bucket' parallel_thresho ... -
这是gsutil中的一个错误(看起来你在这里报告),它将在gsutil 4.23中修复。 This was a bug in gsutil (which it looks like you reported here) and it will be fixed in gsutil 4.23.
-
gsutil 4.20(2016-07-20发布)修改了rsync的变化检测算法 。 它现在比较本地文件的大小和文件修改时间,而不是仅仅将本地文件的大小与其云对应物进行比较。 使用rsync上载文件时,文件修改时间将存储在文件的自定义用户元数据中。 如果不存在,则使用对象创建时间。 gsutil 4.20 (released 2016-07-20) modified the change detection algorithm for rsync. Instead of comparing only the ...
-
如何恢复gsutil命令?(How to restore gsutil command?)[2022-12-16]
它是通过安装的问题 sudo apt-get update && sudo apt-get install google-cloud-sdk 请参阅https://cloud.google.com/sdk/docs/#deb ,您应该使用相同的机制进行升级。 gcloud也是一种包管理器,能够升级自己及其依赖的包。 不幸的是,如果您使用gcloud进行升级,请将其安装在不同的位置。 它可能不起作用,因为需要将新位置添加到您的路径中。 您可以尝试通过apt-get重新安装googcle-cloud-sdk软 ... -
gsutil无法上传“codec无法解码字节”错误的文件(gsutil fails to upload file with “codec can't decode byte” error)[2022-02-06]
这里的问题是包含无效Unicode字符的文件名。 我们更改了gsutil以便为此案例提供更有用的错误消息。 此更改将包含在gsutil 4.4中。 The problem here was a file name containing invalid Unicode chars. We have changed gsutil to provide a more helpful error message for this case. This change will be included in gsuti ...