Skip to main content
TheAzzam
Inspiring
August 22, 2022
Answered

Any way to upload image to an S3 bucket through ExtendScript?

  • August 22, 2022
  • 2 replies
  • 1169 views

In Javascript, to upload files to an S3 bucket, aws-sdk is used. However, I can not import this library in Extendscript. So is there any way for me to perform this operation?

This topic has been closed for replies.
Correct answer Dariusz1989

Build c++ app/exe/python and then do

 

system("myApp.exe" --data "data")
and do it outside photoshop. 

2 replies

Legend
August 22, 2022

You can call either Cyberduck or cURL via command line, both support AWS. On the Mac its fairly straightforward, on Windows I have sample code to use Windows Scripting Host and Powershell to run a cURL script silently (no ugly command window.) You can find this on my Dropbox https://www.dropbox.com/sh/mg817g9a9ymbasi/AADTmXUVxmFfM58bcyYE7yiwa?dl=0

Inspiring
August 23, 2022

Worth mentioning to anyone reading that there is a base64 conversion tool in Lumigraphics's toolkit as well... Which is pretty -word redacted- awesome!

 

@Lumigraphics Are you referring to the zip tool but then modified using curl/cyberduck instead of archive etc.

Or is there a silent cURL script jsx tool already in there and I'm not seeing it?

 

Legend
August 23, 2022

Yes you would call a Powershell script which calls cURL. Here is a sample (uploading to ftp but the idea is the same.)

#Sample Powershell script to upload files to ftp using curl

#Notes: File paths and directories should be edited to suit. Script will fail around 1400 files in a folder, keep it under that.
#If a different ftp account is needed, add a new item to the array with login:pass
#--ssl -k used for ftps account

#edit these variables
$curlpath = "~\curl\bin\curl.exe"
$MasterDir = "~\Pictures\"
$ftpDir = "ftps://ftp.sample.com/"
#subdirectories, logins, file types - (local folder, remote folder, file extension, file type)
$DirArray = ("PDF", "pdf/", ".pdf", "PDF"), ("Small JPEG", "JPEG/1000px/", ".jpg", "JPEG"),`
("Large JPEG", "JPEG/1600px/", ".jpg", "JPEG")
$ArrayCounter = 0
#add item to array for account with different password
$pass = "user:password"

#spreadsheet
$ftp = $ftpDir+"Excel/"
$filelist = "sample.xlsx"
cd ~\Desktop\
Start-Process -FilePath $curlpath -ArgumentList "-T $filelist $ftp -u $pass --ssl -k"

#repeat until end of DirArray
while ($ArrayCounter -lt $DirArray.length)
{
#get parameters for next directory
$Dir = $MasterDir+$DirArray[$ArrayCounter][0]
$RemoteDir = $DirArray[$ArrayCounter][1]
$searchext = $DirArray[$ArrayCounter][2]
$filetype = $DirArray[$ArrayCounter][3]
#if needed for different account
#$pass = $DirArray[$ArrayCounter][4]

#get file listing filtered by $searchext and convert to globbed input for curl
$filelist = dir $Dir ("*"+$searchext)
$filelist = $filelist -replace($searchext,',') -replace ($filetype,"")
$filelist = "{"+$filelist+"}"
$filelist = $filelist -replace(',}',('}'+$searchext)) -replace (' ','')

#launch curl if list is not empty, upload from local directory
if ($filelist -ne "{}")
{
#specify ftp server directory
$ftp = $ftpDir+$RemoteDir
#change local directory
cd $Dir
Start-Process -FilePath $curlpath -ArgumentList "-T $filelist $ftp -u $pass --ssl -k"
}
$ArrayCounter = $ArrayCounter+1
}

 

Dariusz1989Correct answer
Inspiring
August 22, 2022

Build c++ app/exe/python and then do

 

system("myApp.exe" --data "data")
and do it outside photoshop. 

Inspiring
August 22, 2022

I just did system("calc.exe"); in a blank jsx file to test it and it totally works.

That's so incredibly awesome!!! You've given me a whole world of options to explore and play with.

Thank you thank you thank you so much!