diff --git a/emacs/init.org b/emacs/init.org index 5fa429a..96821a7 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -2597,6 +2597,25 @@ Syntax highlighting for Dockerfiles: (general-def kubernetes-overview-mode-map "SPC" leader-map)) #+END_SRC +* AWS +** S3 +#+BEGIN_SRC emacs-lisp + (defun save-to-s3-sentinel (proc event) + (cond ((string-match-p "finished" event) + (progn + (message (concat "Uploaded to " last-s3-url)) + (kill-buffer "*aws-s3*"))) + (t (message "Failed to upload to s3, check *aws-s3* buffer for details")))) + + (defun save-to-s3 (bucket public) + (interactive "MS3 bucket URL (e.g. s3://bucket/filename): \nP") + (let* ((tmp-file (make-temp-file "s3-upload")) + (cmd `("aws" "s3" "cp" ,@(if public '("--acl" "public-read")) ,tmp-file ,bucket))) + (setq last-s3-url bucket) + (write-region (point-min) (point-max) tmp-file) + (let ((proc (apply #'start-process "aws-s3" "*aws-s3*" cmd))) + (set-process-sentinel proc #'save-to-s3-sentinel)))) +#+END_SRC * Lola Some functions to make my day job easier.