File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,20 @@ runs:
40
40
// Get Dropbox access token
41
41
const accessTokenResponse = execSync(`curl -s https://api.dropbox.com/oauth2/token -d refresh_token=${DROPBOX_REFRESH_TOKEN} -d grant_type=refresh_token -d client_id=${DROPBOX_APP_KEY} -d client_secret=${DROPBOX_APP_SECRET}`).toString();
42
42
const accessToken = JSON.parse(accessTokenResponse).access_token;
43
-
44
- // Move the file/folder on Dropbox
45
- const output = execSync(`curl -X POST https://api.dropboxapi.com/2/files/move_v2 -H 'Authorization: Bearer ${accessToken}' -H 'Content-Type: application/json' -d '{"from_path": "${SOURCE_PATH}", "to_path": "${DEST_PATH}"}'`);
46
- console.log('output:', output.toString());
47
- //execSync(`curl -X POST https://api.dropboxapi.com/2/files/move_v2 --header "Authorization: Bearer ${accessToken}" --header "Dropbox-API-Arg: {\\"from_path\\": \\"${SOURCE_PATH}\\",\\"to_path\\": \\"${DEST_PATH}\\"}"`);
43
+ try {
44
+ // Move the file/folder on Dropbox
45
+ const output = execSync(`curl -X POST https://api.dropboxapi.com/2/files/move_v2 -H 'Authorization: Bearer ${accessToken}' -H 'Content-Type: application/json' -d '{"from_path": "${SOURCE_PATH}", "to_path": "${DEST_PATH}"}'`);
46
+
47
+ const parsedResponse = JSON.parse(output.toString());
48
+
49
+ if (parsedResponse.error_summary || parsedResponse.error) {
50
+ throw new Error(parsedResponse.error_summary || parsedResponse.error);
51
+ } else {
52
+ console.log(`${SOURCE_PATH} moved to ${DEST_PATH} successfully`);
53
+ }
54
+ } catch (error) {
55
+ throw new Error(error.message);
56
+ }
48
57
env :
49
58
DROPBOX_APP_KEY : ${{ inputs.DROPBOX_APP_KEY }}
50
59
DROPBOX_APP_SECRET : ${{ inputs.DROPBOX_APP_SECRET }}
You can’t perform that action at this time.
0 commit comments