数据模块中的 blob

Posted

技术标签:

【中文标题】数据模块中的 blob【英文标题】:blob in data module 【发布时间】:2012-03-24 22:37:14 【问题描述】:

我正在使用 drupal 7 中的数据模块,并创建了一个显示我的表格的视图。

但是我的表格中有一个 blob,它正在用内容填充我的页面。有什么方法可以让 blob 显示为链接,并且必须在单击时下载文件。 数据模块也可以访问与settings.php中提到的默认drupal数据库不同的数据库中的表。我在settings.php中添加了另一个具有所需表的数据库,但我无法采用来自那里的表。(它们不会出现在孤立表列表中)。是否有可以更改的地方,以便数据模块只能看到新数据库而不是默认数据库

【问题讨论】:

【参考方案1】:

通过在 theme.inc 中执行此操作解决了第一个问题

if($vars['fields'][$field] == 'content')
    
         $field_output = "<form action=\"download.php\"      
 method=\"POST\"> 
        <input  type=\"submit\" name=\"download\" value=\"Download\"> 
            <input type=\"hidden\" name=\"did\" value=\"$num+1\"> 
                </form>";

    

而download.php需要有这样的东西

 <?php

if(isset($_POST['id'])) 

    $table = 'tablename';
    $download_id = $_POST['id'];
    $q="SELECT * FROM $table where id = $download_id";
    $link = mysqli_connect(...);
    $res = mysqli_query($link,$q);
   if($res)
   
   $row = mysqli_fetch_assoc($res);
    $id = $row['id'];
    $name = $row['name'];
    $status = $row['status'];
    $content = $row['content'];
    header("Content-type: required type");
    header("Content-Disposition: attachment; filename=$name");
    echo $content;
    exit;
   
   else
   echo "Cannot download";


?>

我仍然无法解决第二个问题。

【讨论】:

以上是关于数据模块中的 blob的主要内容,如果未能解决你的问题,请参考以下文章

ImportError:没有名为 azure.storage.blob 的模块(执行 syncdb 时)

sklearn 中 make_blobs模块使用

sklearn 中 make_blobs模块

Python Anaconda 和 azure-storage 模块

sklearn之datasets模块常用功能详细介绍

如何在 Node.js 中创建 Blob?