首页 \ 问答 \ 在mysql中存储卷曲会话cookie(Storing curl session cookies in mysql)

在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
更新时间:2023-09-05 11:09

最满意答案

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 the crcmod 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 setting parallel_threshold='0' above, which will disable this support.

相关问答

更多
  • 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 ...
  • 我不确定在后台使用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文档的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 ...
  • 它是通过安装的问题 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软 ...
  • 这里的问题是包含无效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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。