[Closed] Script to arcive and mail?
Well…anyway… here’s a working example:
(
dnConvert=dotnetClass "System.Convert"
dnUTF8 = dotNetObject "System.Text.UTF8Encoding"
rijn=(dotnetClass "System.Security.Cryptography.SymmetricAlgorithm").Create()
bKey=#(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2)
bIV=#(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6)
arDir = getdir #archives
theINI=arDir+@"\UAS_settings.ini"
fExists=getfilesize theINI
if fExists!=0 then
(
encText=dnConvert.FromBase64String (getINISetting theINI "UAS Settings" "Password")
memStream = dotnetObject "System.IO.MemoryStream"
cStreamMode=(dotnetClass "System.Security.Cryptography.CryptoStreamMode")
cStreamTransform=rijn.CreateDecryptor bKey bIV
cStream=dotnetObject "System.Security.Cryptography.CryptoStream" memStream cStreamTransform cStreamMode.Write
cStream.Write encText 0 encText.Count
cStream.FlushFinalBlock()
cipherBytes=memStream.ToArray()
memStream.Close()
cStream.Close()
dectext=dnUTF8.GetString cipherBytes
theFTP=getINISetting theINI "UAS Settings" "FTP"
theUsername=getINISetting theINI "UAS Settings" "Username"
thePassword=decText
)
else
(
theFTP=@"ftp://ftp.google.com/"
theUsername="anonymous"
thePassword="password"
)
rollout rUpload "Upload"
(
button btn_Archive "Archive" across:2 align:#left
button btn_Upload "Upload" align:#right
progressbar pb_Upload
button btn_site "?" align:#center
local webClient = dotnetObject "System.Net.WebClient"
fn UploadProgressChanged sender args =
(
pb_Upload.value=args.ProgressPercentage
)
fn UploadFileCompleted sender args =
(
if args.Error==undefined then print "Upload finished" else print "An error as occurred"
)
on rUpload open do
(
dotnet.addEventHandler webClient "UploadProgressChanged" UploadProgressChanged
dotnet.addEventHandler webClient "UploadFileCompleted" UploadFileCompleted
)
on btn_Archive pressed do
(
max file archive
)
on btn_Upload pressed do
(
theFile = getFilenameFile maxFilename
theZip = (arDir+@"\"+theFile+".zip")
fExists=getfilesize theZip
if fExists!=0 then
(
print "Upload started"
theRemote=theFTP+theFile+".zip"
theUri=dotnetObject "System.Uri" theRemote
webClient.Credentials = dotnetObject "System.Net.NetworkCredential" theUsername thePassword
webClient.UploadFileAsync theUri theZip
) else print "Upload aborted"
)
on btn_site pressed do
(
process=dotnetclass "System.Diagnostics.Process"
process.start "http://www.dimensao3.com/al"
)
)
rollout sFTP "Setup FTP"
(
edittext txt_host "Host:" text:@"ftp://ftp.google.com" labelOnTop:true
edittext txt_username"Username:" text:"anonymous" labelOnTop:true
edittext txt_password "Password:" text:"password" labelOnTop:true
button btn_save "Save settings"
on btn_save pressed do
(
encText=dnUTF8.GetBytes txt_password.text
memStream = dotnetObject "System.IO.MemoryStream"
cStreamMode=(dotnetClass "System.Security.Cryptography.CryptoStreamMode")
cStreamTransform=rijn.CreateEncryptor bKey bIV
cStream=dotnetObject "System.Security.Cryptography.CryptoStream" memStream cStreamTransform cStreamMode.Write
cStream.Write encText 0 encText.Count
cStream.FlushFinalBlock()
cipherBytes=memStream.ToArray()
memStream.Close()
cStream.Close()
enctext=dnConvert.ToBase64String cipherBytes
deleteFile theINI
setINISetting theINI "UAS Settings" "FTP" theFTP
setINISetting theINI "UAS Settings" "Username" theUsername
setINISetting theINI "UAS Settings" "Password" encText
)
on sFTP open do
(
txt_host.text=theFTP
txt_username.text=theUsername
txt_password.text=thePassword
)
on txt_host changed eText do
(
theFTP=eText
)
on txt_username changed eText do
(
theUsername=eText
)
on txt_password changed eText do
(
thePassword=eText
)
)
mainFloat=newRolloutFloater "Upload Archived Scenes" 300 290
addRollout rUpload mainFloat
addRollout sFTP mainFloat
)
your question was answered? Unless you want somebody to provide the complete code for you, of course.
-
write a Max File archiver.
You could use max’s own File > Archive, but you’ll have to use UIAccessor to set the filename to exactly what you need.
Otherwise, you’ll have to write your own archiver, probably using the asset tracker to get at all the bitmaps, IES files, xref’d files, etc. that you might need. -
Upload the file to an FTP site
See Kameleon’s post.
What’s missing?
Edit: side > site
I’ve actually written the tool but I’m struggling with a minor issue that is to encrypt the password that is saved to an INI file… I’ll post something later, cheers.
Thanks PEN, I for some reason hadn’t seen those! Thanks for the resource, and thanks Kameleon.
Kameleon: ok…i just say…wow!..thanks man…i didn´t expected that. thats so helpful…
ZeBoxx2: well yes…but i am not good with max script and i don´t know much about programing. I was asking for some tutorial, or guide to help me do it. i´m just a noob on it jejejeje…but thanks for your help.
Hey Carlos, no problem. Just download the latest file I’ve attached so you can have multiple FTP’s configured, and remember not to change the filename when archiving or it will error. Cheers.
Thanks a lot…but i just try it…and is not uploading…and another question…how can i to customize?..for example…if i want to put an image or logo…or icon.
Again…thanks for your help!