从剪贴板获取图片遇到点问题:
https://github.com/raycast/extensions/blob/main/extensions/base64/src/util/clipboard.ts 使用这个拓展的例子(用的run-applescript),获取到的剪贴板的是字符串
16:55:59.089 «class PNGf»:«data PNGf89504E470D0A1A0A0000000D494844520000015D00000084080600000033CEF8E400000146694343504943432050726F66696C650000289163606012492C28C861616060C8CD2B290A72775288888C52607FC6C0C4C0CD20CC20CE2093985C5CE01810E00354C200A351C1B76B0C8C20FAB22EC8ACCB2B1F9E7574C854B73061B9A97C95FD05A67A14C095925A9C0CA4FF00716A724151090303630A90AD5C5E5200627700D92245404701D97340EC74087B03889D04611F01AB09097206B26F00D902C919894033184176EB242189A723B1A1F68200B76FA6826F7E5E66497E1101D792014A522B4A40B4737E416551667A46898223309452153CF392F574148C0C8C8C181840610E51FD39081C968C62FB1062F94B18182CBE3130304F4488254D6160D8DEC6C020710B21A6328F8181BF858161DBA182C4A244B80318BFB114A7191B41D83CF60C0CAC77FFFFFFACC1C0C03E9181E1EFC4FFFF7F2FFEFFFFEF62A0F9B719180E540200EF3A61283AA2D80C00000038655849664D4D002A00000008000187690004000000010000001A000000000002A0020004000000010000015DA003000400000001000000840000000093B1A21F00003AFF494441547801ED5D077C14C5177E8410204008107A0BBD17E9BD5769D214A4832808F2171114155044144444144410A40848477<…>
想问一下这种形式怎么转换成 buffer ,file 的格式,这样之后就可以用 sdk 上传了。
目前采用曲线救国的方法, 先执行这段脚本,再用文件路径上传图片,感觉有点麻烦。
set png_data to the clipboard as «class PNGf»
set the_file to open for access POSIX path of (POSIX file "/Users/hello/data/image.png") with write permission
write png_data to the_file
close access the_file