dongqian9567 2013-02-04 05:09
浏览 51
已采纳

从dynamoDB php读取二进制文件

I am trying to write and read binary data from DynamoDB using SDK php 2.

I can write the data to the table but when I read it, it comes in a different format how to cast it back to its original binary format.

$put_response = $dynamodb->putItem(array(
    'TableName' => 'TableName', 
    'Item' => array(
    'Id' => array( 'S' => 'werwer' ), // Primary Key
    'IV' => array( 'B' => openssl_random_pseudo_bytes(50)),
    'Password' => array( 'B' => $encrypt->EncryptER("asdasd") )
    )
    ));

When I read the IV attribute or the Password I get a different value for it, what is the cast that I should do or if there is a function to convert the string back to binary.

This is what I get if I do echo before storing the value in Dynamo �LX�x��ʝ�t]�>0

This is the echo of the variable after reading it from Dynamo GdNMWLt4nZrKnc50XdE+MA==

Thanks

  • 写回答

1条回答 默认 最新

  • dpnhp20440 2013-02-05 02:35
    关注

    The main thing was that the binary data is stored in base64 in DynamoDB even if you provided it in raw format. so to get the raw binary back I had to use

    base64_decode($response->getPath('Item/IV/B'))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog