diff --git a/src/model.lisp b/src/model.lisp index 2d2482e..d8c4655 100644 --- a/src/model.lisp +++ b/src/model.lisp @@ -572,9 +572,9 @@ reference for future projects. This is a learning project after all. (file-length s) :element-type '(unsigned-byte 8)))) (read-sequence vector s) - (storage::write + (rails-to-caveman.storage::write (make-instance 'flex::vector-input-stream :vector vector) 1 "account" - (storage::make-file :name "profile.png" :content-type "image/png")) + (rails-to-caveman.storage::make-file :name "profile.png" :content-type "image/png")) ;; PROBLEM IS IN HERE.... )))))) diff --git a/src/storage.lisp b/src/storage.lisp index 987ad4b..95a5101 100644 --- a/src/storage.lisp +++ b/src/storage.lisp @@ -28,18 +28,19 @@ rails-to-caveman.config::*application-root*)) (defun write (stream id subdirectory file) - ;; (let ((path (ensure-directories-exist - ;; (make-storage-pathname id subdirectory file)))) - (let ((path "/home/craig/Desktop/test.png")) + (let ((path (ensure-directories-exist + (make-storage-pathname id subdirectory file)))) + ;; (let ((path "/home/craig/Desktop/test.png")) (with-open-file (s path :direction :output :if-does-not-exist :create :element-type '(unsigned-byte 8) :if-exists nil) - (write-sequence (slot-value stream 'vector) s :start 0)))) - ;; (if s - ;; (write-sequence (slot-value stream 'vector) s) - ;; (warn "File already exists ~S~&Ignored." path)))) + ;; (write-sequence (slot-value stream 'vector) s :start 0)))) + (format t "[INFO] The Stream is: " s) + (if s + (write-sequence (slot-value stream 'vector) s) + (warn "File already exists ~S~&Ignored." path))))) (defun read (id subdirectory file) (with-open-file (s (make-storage-pathname id subdirectory file) diff --git a/src/web.lisp b/src/web.lisp index 41156ab..ead7c72 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -692,7 +692,7 @@ nil "/users/~D"(mito:object-id user)))))))) (rails-to-caveman.model::filename-of user)))) ((_ nil) ; when specify new one, always remove old one. (rails-to-caveman.model::purge user "account" image-file) - (storage::write (car image) + (rails-to-caveman.storage::write (car image) (mito:object-id user) "account" (make-image-file image))) ((nil _)) ; do not remove, no new one, so do nothing. @@ -707,12 +707,12 @@ nil "/users/~D"(mito:object-id user)))))))) (defun purge (user subdirectory filename) (let (deletedp (id (mito:object-id user))) (dolist (pathname (uiop:directory-files - (storage::make-storage-pathname id subdirectory)) + (rails-to-caveman.storage::make-storage-pathname id subdirectory)) deletedp) - (let ((file (storage::read-from-base64-string (pathname-name pathname)))) - (when (equal filename (storage::file-name file)) + (let ((file (rails-to-caveman.storage::read-from-base64-string (pathname-name pathname)))) + (when (equal filename (rails-to-caveman.storage::file-name file)) (setf deletedp t) - (storage::remove id subdirectory file)))))) + (rails-to-caveman.storage::remove id subdirectory file)))))) (defroute("/account" :method :put)() ) (defroute("/account" :method :delete)() ) @@ -764,7 +764,7 @@ nil "/users/~D"(mito:object-id user)))))))) :token ,(token) :news ,(articles 5) :blogs ,(entries :limit 5))))) - (progn (storage::write (car image) + (progn (rails-to-caveman.storage::write (car image) (mito:object-id user) (format nil "entry~A"entry-id) (make-image-file image)) @@ -832,7 +832,7 @@ nil "/users/~D"(mito:object-id user)))))))) (progn (unless (equal old (rails-to-caveman.model::filename-of entry-image)) (rails-to-caveman.model::purge user subdirectory old) - (storage::write (car image) + (rails-to-caveman.storage::write (car image) (mito:object-id user) subdirectory (make-image-file image))) (mito:save-dao entry-image) @@ -1184,17 +1184,17 @@ nil "/users/~D"(mito:object-id user)))))))) filename size content-type) - (let* ((original-file (storage::make-file :name filename + (let* ((original-file (rails-to-caveman.storage::make-file :name filename :content-type content-type)) (to-load original-file)) - (when size (let ((converted-file (storage::make-file :name filename + (when size (let ((converted-file (rails-to-caveman.storage::make-file :name filename :size size :content-type content-type))) - (unless (storage::probe-file id subdirectory converted-file) - (storage::convert id subdirectory original-file converted-file)) + (unless (rails-to-caveman.storage::probe-file id subdirectory converted-file) + (rails-to-caveman.storage::convert id subdirectory original-file converted-file)) (setf to-load converted-file))) (multiple-value-bind (content length) - (storage::read id subdirectory to-load) + (rails-to-caveman.storage::read id subdirectory to-load) `(,status-code:+ok+ (:content-type ,content-type :content-length ,length) ,content)))) diff --git a/storage/1/account/IygicHJvZmlsZS5wbmciIE5JTCAiaW1hZ2UvcG5nIik= b/storage/1/account/IygicHJvZmlsZS5wbmciIE5JTCAiaW1hZ2UvcG5nIik= new file mode 100644 index 0000000..d41c9c9 Binary files /dev/null and b/storage/1/account/IygicHJvZmlsZS5wbmciIE5JTCAiaW1hZ2UvcG5nIik= differ