Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local function put( sFile )
- assert( type( sFile ) == "string", "String expected, got " .. type( sFile ), 2)
- local sPath = sFile
- assert( not fs.isDir( sPath ), "Cannot upload directories", 2 )
- local sName = fs.getName( sPath )
- local handle = fs.open( sPath, "r" )
- local sText = handle.readAll()
- handle.close()
- local key = "0ec2eb25b6166c0c27a394ae118ad829"
- local response = http.post(
- "http://pastebin.com/api/api_post.php",
- "api_option=paste&" ..
- "api_dev_key=" .. key .. "&" ..
- "api_paste_format=lua&" ..
- "api_paste_name=" .. textutils.urlEncode( sPath ) .. "&" ..
- "api_paste_code=" .. textutils.urlEncode( sText )
- )
- if response then
- local sResponse = response.readAll()
- local sCode = string.match( sResponse, "[^/]+$" )
- response.close()
- return sCode, true
- end
- return nil, false
- end
- local code, success = put(args[1])
- print(code)
- print(success)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement