File upload: get return code 200 and the return is empty

Start date

Due date

Description

Original report: https://forum.mattermost.org/t/api-upload-file-not-uploading/6776

Steps to reproduce
Version 5.7.0.
Laravel PHP curl upload a file via API request:

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => env('MATTERMOST_URL')."/api/v4/files?channel_id=".$channel_id."&filename=".$destinationPath.'/'.$name,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array('files' => $destinationPath.'/'.$name, 'channel_id' => $channel_id),
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer ".$_COOKIE['MMAUTHTOKEN'],
"Content-Type: multipart/form-data"
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

Expected behavior
Sending the file path (which has already been temporarily saved in Laravel storage) and the channel through cURL, should receive the API return as follows:
{
“file_infos”: [
{
“id”: “string”,
“user_id”: “string”,
“post_id”: “string”,
“create_at”: 0,
“update_at”: 0,
“delete_at”: 0,
“name”: “string”,
“extension”: “string”,
“size”: 0,
“mime_type”: “string”,
“width”: 0,
“height”: 0,
“has_preview_image”: true
}
],
“client_ids”: [
“string”
]
}

Observed behavior
Receiving return with empty fields {“file_infos”: [], “client_ids”: []}

QA Test Steps

None

Activity

Show:

Lindy IsherwoodJune 2, 2019 at 7:13 PM

Thanks AB, closing. Resolved for the reporter.

Amy BlaisMay 24, 2019 at 12:43 PM

Looks like this is resolved for the user.

Elias NahumMay 23, 2019 at 11:51 PM

do we want to ask this customer to update their MM server? I cannot reproduce this on 5.11/5.12 or master

Cannot Reproduce
Pinned fields
Click on the next to a field label to start pinning.

Details

Mana

Assignee

QA Assignee

Reporter

Sprint

Checklist

Created March 8, 2019 at 7:49 PM
Updated June 2, 2019 at 7:13 PM
Resolved May 24, 2019 at 12:43 PM