Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Dropbox?V=1
QUERY_STRINGV=1
CONTENT_TYPE
DOCUMENT_URI/revision/Dropbox
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.59.177
REMOTE_PORT21148
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.145.74.54
HTTP_CF_RAY87df3ad58c021253-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_REFERERhttps://nikit.tcl-lang.org/revision/Dropbox?V=1
HTTP_CF_CONNECTING_IP3.145.74.54
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: CODE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: CODE -> END} {}} CALL {my render_wikit Dropbox {** Access to your personal Dropbox **

I recently wanted to download and upload files from my Dropbox. Turns out that this is easy to do in Tcl.

If all you need is access to your own Dropbox, you don't have to implement the authorization process. Instead:

   1. Go to https://www.dropbox.com/ and sign into your account.
   1. Go to the "App Console" at https://www.dropbox.com/developers/apps
   1. Click on "Create app".
   11. What type of app do you want to create? Select "Dropbox API app".
   11. What type of data does your app need to store on Dropbox? Select "Files and datastores".
   11. Can your app be limited to its own folder? Select according to your preference. For this example, choose "Yes - My app only needs access to files it creates."
   11. If you chose "No" to the previous question, Dropbox will also ask you what types of files the app needs to access. For full access, select "All file types -- My app needs access to a user's full Dropbox."
   11. Provide an app name (for simplicity, just a random string).
   1. After creating the app, find the "OAuth 2" section.
   1. Click on "Generate access token".
   1. You will get the access token (a very long string). Copy this token to your app.

*** Prerequisites ***

You need HTTP and TLS:

 package require http
 package require tls
 http::register https 443 ::tls::socket

*** File Upload ***

Now let's upload some file to your Dropbox. The basic idea is:

   * The base URL for uploading is "https://api-content.dropbox.com/1/files_put/auto", everything after that is the path into your Dropbox. If you chose that the app is limited to its own folder, this path is "chrooted" to the "/Apps/<app-name>" folder in your Dropbox.
   * Note that the file name must be URL-encoded, e.g., space characters must be replaced with %20.
   * Send an HTTP PUT-request for the desired URL with the file contents as body.
   * The HTTP headers must include a line "Authorization: Bearer ${access_token}", where access_token is copied from above.

Assuming that $file is the URL-encoded path to the file in your Dropbox and $content is the data you would like to upload, this then looks like:

 set file "/test.txt"
 set contents "Hello World!"
 set access_token "<copy and paste from above>"
 set base "https://api-content.dropbox.com/1/files_put/auto"
 set url "${base}${file}"
 set contentLength [string length $content]
 set contentType "application/binary"
 set access_token "<copy and paste from above>"
 set headers [list Content-Length $contentLength Host api-content.dropbox.com Authorization "Bearer $access_token"]

 set token [http::geturl $url -headers $headers -method PUT -type $contentType -query $content]
 http::wait $token

If the upload is successful, the server responds with a 200 status code and an HTTP body with some useful information in [JSON] format.

*** File Download ***

File download is even easier:

   * The base URL for downloading is "https://api-content.dropbox.com/1/files/auto". (Same rules as above.)
   * Send an HTTP GET-request for the desired URL.
   * The HTTP headers must include a line "Authorization: Bearer ${access_token}", where access_token is copied from above.

Again assuming that $file is the URL-encoded path to the file in your Dropbox:

 set file "/test.txt"
 set access_token "<copy and paste from above>"
 set base "https://api-content.dropbox.com/1/files/auto"
 set url "${base}${file}"
 set headers [list Host api-content.dropbox.com Authorization "Bearer $access_token"]

 set token [http::geturl $url -headers $headers]
 http::wait $token

If the download is successful, the server responds with a 200 status code, and the HTTP body will contain the file contents:

 set contents [http::data $token]

Some file metadata is also returned in the server response's "x-dropbox-metadata" header, again in JSON format.

*** Authorization ***

Things are more complex if you would like to access someone else's Dropbox. The user must be redirected to Dropbox' Web site (which has to be done outside Tcl) to authorize access. The authorization flow is described in the documentation referenced below.

*** References ***

   * https://www.dropbox.com/developers/core/docs Documentation of the Dropbox Core API.
   * http://tools.ietf.org/html/rfc6749 The OAuth 2.0 Authorization Framework.

======} regexp2} CALL {my render Dropbox {** Access to your personal Dropbox **

I recently wanted to download and upload files from my Dropbox. Turns out that this is easy to do in Tcl.

If all you need is access to your own Dropbox, you don't have to implement the authorization process. Instead:

   1. Go to https://www.dropbox.com/ and sign into your account.
   1. Go to the "App Console" at https://www.dropbox.com/developers/apps
   1. Click on "Create app".
   11. What type of app do you want to create? Select "Dropbox API app".
   11. What type of data does your app need to store on Dropbox? Select "Files and datastores".
   11. Can your app be limited to its own folder? Select according to your preference. For this example, choose "Yes - My app only needs access to files it creates."
   11. If you chose "No" to the previous question, Dropbox will also ask you what types of files the app needs to access. For full access, select "All file types -- My app needs access to a user's full Dropbox."
   11. Provide an app name (for simplicity, just a random string).
   1. After creating the app, find the "OAuth 2" section.
   1. Click on "Generate access token".
   1. You will get the access token (a very long string). Copy this token to your app.

*** Prerequisites ***

You need HTTP and TLS:

 package require http
 package require tls
 http::register https 443 ::tls::socket

*** File Upload ***

Now let's upload some file to your Dropbox. The basic idea is:

   * The base URL for uploading is "https://api-content.dropbox.com/1/files_put/auto", everything after that is the path into your Dropbox. If you chose that the app is limited to its own folder, this path is "chrooted" to the "/Apps/<app-name>" folder in your Dropbox.
   * Note that the file name must be URL-encoded, e.g., space characters must be replaced with %20.
   * Send an HTTP PUT-request for the desired URL with the file contents as body.
   * The HTTP headers must include a line "Authorization: Bearer ${access_token}", where access_token is copied from above.

Assuming that $file is the URL-encoded path to the file in your Dropbox and $content is the data you would like to upload, this then looks like:

 set file "/test.txt"
 set contents "Hello World!"
 set access_token "<copy and paste from above>"
 set base "https://api-content.dropbox.com/1/files_put/auto"
 set url "${base}${file}"
 set contentLength [string length $content]
 set contentType "application/binary"
 set access_token "<copy and paste from above>"
 set headers [list Content-Length $contentLength Host api-content.dropbox.com Authorization "Bearer $access_token"]

 set token [http::geturl $url -headers $headers -method PUT -type $contentType -query $content]
 http::wait $token

If the upload is successful, the server responds with a 200 status code and an HTTP body with some useful information in [JSON] format.

*** File Download ***

File download is even easier:

   * The base URL for downloading is "https://api-content.dropbox.com/1/files/auto". (Same rules as above.)
   * Send an HTTP GET-request for the desired URL.
   * The HTTP headers must include a line "Authorization: Bearer ${access_token}", where access_token is copied from above.

Again assuming that $file is the URL-encoded path to the file in your Dropbox:

 set file "/test.txt"
 set access_token "<copy and paste from above>"
 set base "https://api-content.dropbox.com/1/files/auto"
 set url "${base}${file}"
 set headers [list Host api-content.dropbox.com Authorization "Bearer $access_token"]

 set token [http::geturl $url -headers $headers]
 http::wait $token

If the download is successful, the server responds with a 200 status code, and the HTTP body will contain the file contents:

 set contents [http::data $token]

Some file metadata is also returned in the server response's "x-dropbox-metadata" header, again in JSON format.

*** Authorization ***

Things are more complex if you would like to access someone else's Dropbox. The user must be redirected to Dropbox' Web site (which has to be done outside Tcl) to authorize access. The authorization flow is described in the documentation referenced below.

*** References ***

   * https://www.dropbox.com/developers/core/docs Documentation of the Dropbox Core API.
   * http://tools.ietf.org/html/rfc6749 The OAuth 2.0 Authorization Framework.

======}} CALL {my revision Dropbox} CALL {::oo::Obj4769120 process revision/Dropbox} CALL {::oo::Obj4769118 process}

-errorcode

NONE

-errorinfo

Unknow state transition: CODE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4