Copy link to clipboard
Copied
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?
1 Correct answer
Build c++ app/exe/python and then do
system("myApp.exe" --data "data")
and do it outside photoshop.
Explore related tutorials & articles
Copy link to clipboard
Copied
Build c++ app/exe/python and then do
system("myApp.exe" --data "data")
and do it outside photoshop.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Sorry but could you elaborate more on the building the app part? What will the app contain?
Copy link to clipboard
Copied
I built a python exe containing the following code:
from photoshop import Session
with Session() as ps:
ps.app.activeDocument.name = "1"
If I run it using system("test.exe"), it does nothing. Why?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
}
Copy link to clipboard
Copied
Regarding aws s3, where would the access key and secret access keys go? Could you help modify this code for aws?
Copy link to clipboard
Copied
Nope, I don't use Amazon services. I'd post on Amazon forums.
https://repost.aws/questions/QUYzA4Xr89RTKYL1uZ2C3qvg/aws-cli-uploading-files-with-curl

