Skip to content

Commit 86b7dce

Browse files
authored
Revert "Fix uploading activity as a file"
1 parent 6de878c commit 86b7dce

File tree

3 files changed

+100
-130
lines changed

3 files changed

+100
-130
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
],
2222
"require": {
2323
"php": "^7.4 || ^8.0",
24+
"ext-curl": "*",
2425
"ext-json": "*",
2526
"guzzlehttp/guzzle": "^6.3 || ^7.0.1",
2627
"league/oauth2-client": "~2.3"

src/Strava/API/Service/REST.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ public function createActivity(string $name, string $type, string $start_date_lo
346346
public function uploadActivity(string $file, string $activity_type = null, string $name = null, string $description = null, int $private = null, int $trainer = null, int $commute = null, string $data_type = null, string $external_id = null)
347347
{
348348
$path = 'uploads';
349-
350-
$data = [
349+
$parameters['query'] = [
351350
'activity_type' => $activity_type,
352351
'name' => $name,
353352
'description' => $description,
@@ -356,23 +355,10 @@ public function uploadActivity(string $file, string $activity_type = null, strin
356355
'commute' => $commute,
357356
'data_type' => $data_type,
358357
'external_id' => $external_id,
358+
'file' => curl_file_create($file),
359+
'file_hack' => '@' . ltrim($file, '@'),
359360
'access_token' => $this->getToken(),
360361
];
361-
$parameters = [
362-
'multipart' => [
363-
[
364-
'name' => 'file',
365-
'contents' => fopen($file, 'r'),
366-
'filename' => basename($file),
367-
],
368-
],
369-
];
370-
foreach ($data as $key => $value) {
371-
$parameters['multipart'][] = [
372-
'name' => $key,
373-
'contents' => $value,
374-
];
375-
}
376362

377363
return $this->getResponse('POST', $path, $parameters);
378364
}

0 commit comments

Comments
 (0)