dqlk31541 2019-07-31 14:39
浏览 38

Podio API不允许上传.msg文件

I am using the Podio API from a Drupal website (with the Podio PHP client). Using it several types of files (all that I allow from a custom webform) are being uploaded and attached to Podio items without any problems.

The only files that seem impossible to be uploaded are .msg files. On uploading a .msg file the following message is received:

PodioBadRequestError: PodioBadRequestError in Podio::request() 

Which doesn't help me a lot.

The .msg file also doesn't seem to be excluded here: https://developers.podio.com/doc/files

Is it at all possible to upload .msg files with the Podio API, and if so would anyone have an idea what I could be doing wrong?

Thanks in advance.

UPDATE

Some of the code I have used to post the items to Podio

PodioIncidentItem: this is the item that gets published to Podio

  /**
  * Post incident to Podio
  */
  public function postToPodio() {
    $podioConnection = new PodioAPIConnection();
    $podioConnection->setupAndAuthenticate();

    if(!$this->podio_link_available) {
      $this->incident_description = t('Ticket by: ' . $this->requested_by . '<br /><br />' . $this->incident_description);
      $this->requested_by = NULL;
    }

    $fields = new PodioItemFieldCollection(array(
      new PodioTextItemField(array(
        "external_id" => "title",
        "values" => $this->short_title,
      )),
      new PodioAppItemField(array(
        "external_id" => "username",
        "values" => array((int)$this->requested_by),
      )),
      new PodioAppItemField(array(
        "external_id" => "sdt-user",
        "values" => array((int)$this->sdt_user),
      )),
      new PodioCategoryItemField(array(
        "external_id" => "contactmethod",
        "values" => (int)$this->contactmethod,
      )),
      new PodioTextItemField(array(
        "external_id" => "text",
        "values" => $this->incident_description,
      )),
      new PodioAppItemField(array(
        "external_id" => "catalog-selection",
        "values" => array((int)$this->catalog_selection),
      )),
      new PodioCategoryItemField(array(
        "external_id" => "urgency",
        "values" => (int)$this->urgency,
      )),
      new PodioCategoryItemField(array(
        "external_id" => "impact",
        "values" => (int)$this->impact,
      )),
      new PodioCategoryItemField(array(
        "external_id" => "status",
        "values" => (int)$this->status,
      )),
      new PodioCategoryItemField(array(
        "external_id" => "source-ticket",
        "values" => (int)$this->source_ticket,
      )),
    ));

    $item = new PodioItem(array(
      'app' => new PodioApp((int)$this->config->get('podioapi.incidents_app_id')),
      'fields' => $fields
    ));

    // Save the new item
    $response = $item->save();

    // Add the uploaded files to the Podio item
    foreach($this->fids as $fid) {
      $file = File::load($fid);
      $file_name = $file->getFilename();
      $uri = $file->getFileUri();
      $base_url = file_create_url("public://");
      $uri_resolved = str_replace('public://', '', $uri);
      $url = $base_url . $uri_resolved;
      $upload_result = PodioFileExtended::uploadFromURL($url);
      $file_id = $upload_result->file_id;
      $attributes = array('ref_type' => 'item', 'ref_id' => $response->item_id);
      PodioFile::attach($file_id, $attributes);
    }

    return $response;
  }

PodioFileExtended: Extended version of the Podio PHP API PodioFile class, this class was extended to enable the upload from URL option

/**
 * @see https://developers.podio.com/doc/files
 */
class PodioFileExtended extends PodioObject {
  public function __construct($attributes = array()) {
    $this->property('file_id', 'integer', array('id' => true));
    $this->property('link', 'string');
    $this->property('perma_link', 'string');
    $this->property('thumbnail_link', 'string');
    $this->property('hosted_by', 'string');
    $this->property('name', 'string');
    $this->property('description', 'string');
    $this->property('mimetype', 'string');
    $this->property('size', 'integer');
    $this->property('context', 'hash');
    $this->property('created_on', 'datetime');
    $this->property('rights', 'array');

    $this->has_one('created_by', 'ByLine');
    $this->has_one('created_via', 'Via');
    $this->has_many('replaces', 'File');

    $this->init($attributes);
  }

  /**
   * @see https://developers.podio.com/doc/files/upload-file-1004361
   */
  public static function uploadFromURL($url) {
    return self::member(Podio::post("/file/from_url/", array('url' => $url)));
  }
}

UPDATE 2

Some more information we have discovered in the meanwhile

Drupal out of the box assigns the application/octet-stream MIME type to .msg files, which is a general MIME type for every custom file type that is not recognised. The MIME type should actually be application/vnd.ms-outlook.

The Podio API doesn't allow files with MIME type application/octet-stream (https://developers.podio.com/doc/files).

But after mapping the .msg files to the correct MIME type, Podio still won't allow it.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题