Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uploading directories #125

Open
Ambrevar opened this issue Sep 23, 2022 · 4 comments · May be fixed by #127
Open

Allow uploading directories #125

Ambrevar opened this issue Sep 23, 2022 · 4 comments · May be fixed by #127

Comments

@Ambrevar
Copy link

At the moment sending a request with a parameter like

("file" #p"/path/to/dir/" :content-type "application/x-directory")

fails because send-content tries to read the dir.
Suggested fix in send-content:

((pathnamep content)
           (when (uiop:file-exists-p content)
             (with-open-file (from content :element-type 'octet)
               ;; calls itself with a stream now
               (send-content from stream))))

For context, I'm trying to upload directories to IPFS:

http://docs.ipfs.tech.ipns.localhost:8080/reference/kubo/rpc/#api-v0-add

@Ambrevar
Copy link
Author

Also then the filename must be set properly in make-form-data-function.

Suggested fix:

(defun basename (pathname)
  (first (last (pathname-directory
                    ;; Ensure directory _after_ truenamizing, otherwise if
                    ;; non-directory file exists it may not yield a directory.
                    (uiop:ensure-directory-pathname
                     (uiop:ensure-pathname pathname :truenamize t)))))

(defun make-form-data-function (parameters boundary external-format-out)
  ; ...
  (pathname (basename file-source))
;...

@Ambrevar
Copy link
Author

Ambrevar commented Oct 9, 2022

@stassats Friendly ping :)

@stassats
Copy link
Member

stassats commented Oct 9, 2022

I don't see a pull request linked to this.

@Ambrevar Ambrevar linked a pull request Oct 26, 2022 that will close this issue
@Ambrevar
Copy link
Author

Ambrevar commented Oct 26, 2022

See #127.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants