I'm having a lot of difficulty getting file uploading to work using
Teapot/Zinc. The documentation is not entirely clear about how it's
supposed to work, and the example provided doesn't quite work. I'm
referring to section "4.6 Submitting HTML Forms" in "Enterprise Pharo – a
Web Perspective."

Here's my setup...

I have a Teapot route like:

GET: '/upload-handler' -> [ :req | self uploadHandler: req ];

where

uploadHandler: req
   ^ '<div>
      <form method="POST" action="upload-handler"
enctype="multipart/form-data">
         <input type="file" name="fileupload">
         <input type="submit" value="Upload!">
      </form>
      </div>'

I have a submission form like:

GET: '/submission' -> [ :req | self submissionPage: req ];
POST: '/submission' -> [ :req | self handleSubmission: req ];

where

submissionPage: req
   ^ '<div>
      <form method="POST">
         <input type="file" name="fileupload" value="">
         <input type="submit" value="Submit">
      </form>
      </div>'

handleSubmission: req
   ZnClient new
      url: 'http://174.117.171.194/upload-handler';
      addPart: (ZnMimePart
         fieldName: 'fileupload' fileNamed: 'S1-ABCD012345.st' );
      post.

When I submit the submission form, I get "FileDoesNotExist: File @
/S1-ABCD012345.st".

It doesn't matter what path I use to get to S1-ABCD012345.st. I tried
"/Users/richardeng/Documents". I tried "/Documents". I tried "/". I don't
know what path it's looking for. The file is there – there's no reason why
it can't find it.

I guess I'm just not understanding how this whole thing is supposed to
work. Any ideas?

Richard

Reply via email to