Sample code for 30+ languages & platforms
Lua

Empty Trash

See more Google Drive Examples

Permanently deletes all of the user's trashed files.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local success = true

-- It requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.

-- This example uses a previously obtained access token having permission for the
-- Google Drive scope.

local gAuth = chilkat.AuthGoogle.new()
gAuth.access_token = "GOOGLE-DRIVE-ACCESS-TOKEN"

local rest = chilkat.Rest.new()

-- Connect using TLS.
local bAutoReconnect = true
success = rest:connect("www.googleapis.com", 443, true, bAutoReconnect)

-- Provide the authentication credentials (i.e. the access token)
rest:set_auth_google(gAuth)

local jsonResponse = rest:full_request_no_body("DELETE", "/drive/v3/files/trash")
if not rest.last_method_success then
    print(rest.last_error_text)
    return
end

-- A successful response will have a status code equal to 204 and the response body is empty.
-- (If not successful, then there should be a JSON response body with information..)
if rest.response_status_code ~= 204 then
    print("response status code = " .. rest.response_status_code)
    print("response status text = " .. rest.response_status_text)
    print("response header: " .. rest.response_header)
    print("response JSON: " .. jsonResponse)
    return
end

print("Trash Emptied!")