You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To upload a file you'll have to pass in the `data_type` as specified in Strava's API reference as well as a string `file` designating the `<filepath>/<filename>`. If you want to get updates on the status of your upload pass in `statusCallback` along with the rest of your `args` - the wrapper will check on the upload once a second until complete.
189
+
To upload a file you'll have to pass in the `data_type` as specified in Strava's API reference as well as a string `file` designating the `<filepath>/<filename>`. By default no status polling is performed—the promise resolves immediately with the initial upload response. To wait until processing is complete, set `maxStatusChecks` (e.g. `300` for ~5 minutes at 1s intervals); the promise will then resolve with the final upload result.
190
190
191
191
Example usage:
192
192
193
193
```js
194
194
conststrava=require('strava-v3');
195
+
// Resolve immediately after posting
195
196
constpayload=awaitstrava.uploads.post({
197
+
data_type:'gpx',
198
+
file:'data/your_file.gpx',
199
+
name:'Epic times'
200
+
});
201
+
202
+
// Or wait until processing is complete (polls once per second, up to maxStatusChecks times)
* @property {number} [maxStatusChecks] - Max polling attempts when using statusCallback (default 300 ≈ 5 min at 1s).
19
+
* @property {number} [maxStatusChecks] - Default: no status polling; promise resolves immediately with the initial upload response. If set to a positive number, poll until upload is done or this many attempts (e.g. 300 ≈ 5 min at 1s); promise then resolves with the final Upload.
21
20
* @property {Record<string, string>} [formData] - Set by post(); do not pass.
22
21
*/
23
22
@@ -50,7 +49,7 @@ var uploads = function (client) {
50
49
}
51
50
52
51
/**
53
-
* Uploads a file to create a new activity; optionally polls status via statusCallback until done.
52
+
* Uploads a file to create a new activity. By default returns immediately with the initial response. If maxStatusChecks > 0, polls until upload is done and resolves with the final Upload.
54
53
* @param {PostUploadArgs} args
55
54
* @returns {Promise<Upload>}
56
55
*/
@@ -76,62 +75,49 @@ uploads.prototype.post = async function (args) {
76
75
77
76
constresponse=awaitthis.client.postUpload(args)
78
77
79
-
// if no statusCallback, just return after posting upload
0 commit comments