Search Results

Search found 485 results on 20 pages for 'multipart'.

Page 2/20 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Youtube API upload - Incomplete Multipart body error

    - by Blerim J
    Hello, I'm trying to upload videos in Youtube through HttpWebRequest. Everything seems to be fine when uploading following the example given in API documentation. I see that request is being formed correctly, with content and token sent but I receive "Incomplete multipart body" as response. Thanks Blerim public bool YouTubeUpload() { string newLine = "\r\n"; //token and url are retrieved from YouTube at runtime. string token = string.Empty; string url = string.Empty; // construct the command url url = url + "?nexturl=http://www.mywebsite.com/"; // get a unique string to use for the data boundary string boundary = Guid.NewGuid().ToString().Replace("-", string.Empty); foreach (string file in Request.Files) { HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase; if (hpf.ContentLength == 0) continue; // get info about the file and open it for reading Stream fs = hpf.InputStream; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.ContentType = "multipart/form-data; boundary=" + boundary; webRequest.Method = "POST"; webRequest.KeepAlive = true; webRequest.Credentials = System.Net.CredentialCache.DefaultCredentials; MemoryStream memoryStream = new MemoryStream(); StreamWriter writer = new StreamWriter(memoryStream); //token writer.Write("--" + boundary + newLine); writer.Write("Content-Disposition: form-data; name=\"{0}\"{1}{2}", "token", newLine, newLine); writer.Write(token); writer.Write(newLine); //Video writer.Write("--" + boundary + newLine); writer.Write("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"{2}", "File1", hpf.FileName, newLine); writer.Write("Content-Type: {0}" + newLine + newLine, hpf.ContentType); writer.Flush(); byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes(string.Format("--{0}--{1}", boundary, newLine)); webRequest.ContentLength = memoryStream.Length + fs.Length + boundarybytes.Length; Stream webStream = webRequest.GetRequestStream(); // write the form data to the web stream memoryStream.Position = 0; byte[] tempBuffer = new byte[memoryStream.Length]; memoryStream.Read(tempBuffer, 0, tempBuffer.Length); memoryStream.Close(); webStream.Write(tempBuffer, 0, tempBuffer.Length); // write the file to the stream int size; byte[] buf = new byte[1024 * 10]; do { size = fs.Read(buf, 0, buf.Length); if (size > 0) webStream.Write(buf, 0, size); } while (size > 0); // write the trailer to the stream webStream.Write(boundarybytes, 0, boundarybytes.Length); webStream.Close(); fs.Close(); //fails here. Error - Incomplete multipart body. WebResponse webResponse = webRequest.GetResponse(); } return true; }

    Read the article

  • Third party multipart request in playframework

    - by Brian
    I'm making an application to post photos to yfrog and twitpic and I am having a little trouble figuring out how to set the parameters. Here is my code: public static Result index() { HttpClient httpclient = new DefaultHttpClient(); WSRequestHolder holder = WS.url("http://api.twitpic.com/2/upload.json"); holder.setHeader("Authorization", ""); return async(holder.post("").map(new Function<WS.Response, Result>() { public Result apply(WS.Response response) { return ok(response.getBody()); } })); } Now, I don't expect this to actually get an ok response from the server, as I am just testing the responses that I get back from the server, and that is one that says I need to provide the api key. I figured as much, but I'm not sure of the syntax for providing that parameter, as I need to also give the name of the file and the file. I tried setting holder.post("key=somekey"), with the hope that I would get a different error message (like the key you provided is invalid) but I just get the same error. I'm assuming that I probably need to send it in the for of a multipart request, but I am not very experienced with this kind of request and can't find any play documentation on how to create a multipart request, other than in an html form. Any suggestions and help will be much appreciated. And fyi, I do know that there are yfrog and twitpic java classes to handle this kind of stuff, but I want to do it myself, more so for learning how to do this kind of stuff. Thanks in advance!

    Read the article

  • Upload files with HTTPWebrequest (multipart/form-data)

    - by dr. evil
    Is there any class, library or some piece of code which will help me to upload files with HTTPWebrequest? Edit 2: I do not want to upload to a WebDAV folder or something like that. I want to simulate a browser, so just like you upload your avatar to a forum or upload a file via form in a web application. Upload to a form which uses a multipart/form-data. Edit: WebClient is not cover my requirements, so I'm looking for a solution with HTTPWebrequest.

    Read the article

  • PHP uploads file - enctype="multipart/form-data" issue

    - by user147685
    Hi all, I have this upload code. there are no problem running it individually, but when i try to add into my other codes, it did not get the $_files parameter. Im guessing it was becoz of enctype="multipart/form-data" in the form tag, based on this post: http://stackoverflow.com/questions/1695246/why-file-upload-didnt-work-without-enctype the enctype is needed. SO my problem is, how can i do upload files without concern to this? can we juz change the code structure so that it will be compatible with other codes? if($_POST['check']){ $faillampiran=$_POST['faillampiran']; $file=$_FILES['faillampiran']["name"]; $fileSize = $_FILES['faillampiran']['size']; $fileType = $_FILES['faillampiran']['type']; if ($_FILES["faillampiran"]["error"] > 0 ) { echo "Return Code: " . $_FILES["faillampiran"]["error"] . "<br />"; } else { move_uploaded_file($_FILES["faillampiran"]["tmp_name"],"upload/" . $_FILES["faillampiran"]["name"]); echo '<table align = "center">'; echo "<tr><td>"; echo "Your file has been successfully stored."; echo "</td></tr>"; echo '</table>'; } } ?> <form method="post" name="form1" id="form1" enctype="multipart/form-data"> <tr><td></td><td><input type="hidden" name="MAX_FILE_SIZE" value=""> </td> </tr> <tr><td> Please choose a file</td><td>:</td></tr> <tr> <input type="file" size="50" name="faillampiran" alt="faillampiran" id="faillampiran" 1value= "<?=$faillampiran;?>" /> <tr align = "center"><td colspan = "3"><input type="submit" value="Hantar" name="check"/></td></tr> </tr></form> thank you.

    Read the article

  • Order of parts in SMTP multipart messages

    - by Chris
    Hi, I'd like to know how to build an SMTP multipart message in the correct order so that it will render correctly on the iPhone mail client (rendering correctly in GMail). I'm using Javamail to build up an email containing the following parts: A body part with content type "text/html; UTF-8" An embedded image attachment. A file attachment I am sending the mail via GMail SMTP (via SSL) and the mail is sent and rendered correctly using a GMail account, however, the mail does not render correctly on the iPhone mail client. On the iPhone mail client, the image is rendered before the "Before Image" text when it should be rendered afterwards. After the "Before Image" text there is an icon with a question mark (I assume it means it couldn't find the referenced CID). I'm not sure if this is a limitation of the iPhone mail client or a bug in my mail sending code (I strongly assume the latter). I think that perhaps the headers on my parts might by incorrect or perhaps I am providing the multiparts in the wrong order. I include the text of the received mail as output by gmail (which renders the file correc Message-ID: <[email protected]> Subject: =?UTF-8?Q?Test_from_=E3=82=AF=E3=83=AA=E3=82=B9?= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_0_20870565.1274154021755" ------=_Part_0_20870565.1274154021755 Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-ID: <20100518124021763_368238_0> iVBORw0K ----- TRIMMED FOR CONCISENESS 6p1VVy4alAAAAABJRU5ErkJggg== ------=_Part_0_20870565.1274154021755 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit <html><head><title>Employees Favourite Foods</title> <style> body { font: normal 8pt arial; } th { font: bold 8pt arial; white-space: nowrap; } td { font: normal 8pt arial; white-space: nowrap; } </style></head><body> Before Image<br><img src="cid:20100518124021763_368238_0"> After Image<br><table border="0"> <tr> <th colspan="4">Employees Favourite Foods</th> </tr> <tr> <th align="left">Name</th><th align="left">Age</th><th align="left">Tel.No</th><th align="left">Fav.Food</th> </tr> <tr style="background-color:#e0e0e0"> <td>Chris</td><td>34</td><td>555-123-4567</td><td>Pancakes</td> </tr> </table></body></html> ------=_Part_0_20870565.1274154021755 Content-Type: text/plain; charset=us-ascii; name=textfile.txt Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=textfile.txt This is a textfile with numbers counting from one to ten beneath this line: one two three four five six seven eight nine ten(no trailing carriage return) ------=_Part_0_20870565.1274154021755-- Even if you can't assist me with this, I would appreciate it if any members of the forum could forward me a (non-personal) mail that includes inline images (not external hyperlinked images though). I just need to find a working sample then I can move past this. Thanks, Chris.

    Read the article

  • multipart file-upload post request from java

    - by Martin
    I'm trying to make a program that uploads a image to a webserver that accepts multipart file-uploads. More specificly i want to make a http POST request to http://iqs.me that sends a file in the variable "pic". I've made a lot of tries but i don't know if i've even been close. The hardest part seems to be to get a HttpURLConnection to make a request of the type POST. The response i get looks like it makes a GET. (And i want to do this without any third party libs) UPDATE: non-working code goes here (no errors but doesn't seem to do a POST): HttpURLConnection conn = null; BufferedReader br = null; DataOutputStream dos = null; DataInputStream inStream = null; InputStream is = null; OutputStream os = null; boolean ret = false; String StrMessage = ""; String exsistingFileName = "myScreenShot.png"; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1*1024*1024; String responseFromServer = ""; String urlString = "http://iqs.local.com/index.php"; try{ FileInputStream fileInputStream = new FileInputStream( new File(exsistingFileName) ); URL url = new URL(urlString); conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setUseCaches(false); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary); dos = new DataOutputStream( conn.getOutputStream() ); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"pic\";" + " filename=\"" + exsistingFileName +"\"" + lineEnd); dos.writeBytes(lineEnd); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); buffer = new byte[bufferSize]; bytesRead = fileInputStream.read(buffer, 0, bufferSize); while (bytesRead > 0){ dos.write(buffer, 0, bufferSize); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); } dos.writeBytes(lineEnd); dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); fileInputStream.close(); dos.flush(); dos.close(); }catch (MalformedURLException ex){ System.out.println("Error:"+ex); }catch (IOException ioe){ System.out.println("Error:"+ioe); } try{ inStream = new DataInputStream ( conn.getInputStream() ); String str; while (( str = inStream.readLine()) != null){ System.out.println(str); } inStream.close(); }catch (IOException ioex){ System.out.println("Error: "+ioex); }

    Read the article

  • multipart file-upload post request from java

    - by Martin
    I'm trying to make a program that uploads a image to a webserver that accepts multipart file-uploads. More specificly i want to make a http POST request to http://iqs.me that sends a file in the variable "pic". I've made a lot of tries but i don't know if i've even been close. The hardest part seems to be to get a HttpURLConnection to make a request of the type POST. The response i get looks like it makes a GET. (And i want to do this without any third party libs) UPDATE: non-working code goes here (no errors but doesn't seem to do a POST): HttpURLConnection conn = null; BufferedReader br = null; DataOutputStream dos = null; DataInputStream inStream = null; InputStream is = null; OutputStream os = null; boolean ret = false; String StrMessage = ""; String exsistingFileName = "myScreenShot.png"; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int bytesRead, bytesAvailable, bufferSize; byte[] buffer; int maxBufferSize = 1*1024*1024; String responseFromServer = ""; String urlString = "http://iqs.local.com/index.php"; try{ FileInputStream fileInputStream = new FileInputStream( new File(exsistingFileName) ); URL url = new URL(urlString); conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestMethod("POST"); conn.setUseCaches(false); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary); dos = new DataOutputStream( conn.getOutputStream() ); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"pic\";" + " filename=\"" + exsistingFileName +"\"" + lineEnd); dos.writeBytes(lineEnd); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); buffer = new byte[bufferSize]; bytesRead = fileInputStream.read(buffer, 0, bufferSize); while (bytesRead > 0){ dos.write(buffer, 0, bufferSize); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); } dos.writeBytes(lineEnd); dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); fileInputStream.close(); dos.flush(); dos.close(); }catch (MalformedURLException ex){ System.out.println("Error:"+ex); }catch (IOException ioe){ System.out.println("Error:"+ioe); } try{ inStream = new DataInputStream ( conn.getInputStream() ); String str; while (( str = inStream.readLine()) != null){ System.out.println(str); } inStream.close(); }catch (IOException ioex){ System.out.println("Error: "+ioex); }

    Read the article

  • Issue with multipart upload in servlet on seam

    - by stacker
    I created a servlet wich works fine when deployed in a separate war file, but I intend to use it as part of a seam application. I use commons-fileupload but the iterator (see snippet) returns false (only when included in the seam-app). Any ideas? protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { String action = request.getParameter( "action" ); if ( ServletFileUpload.isMultipartContent( request ) ) { log.info( "MULTIPART" ); } ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter = upload.getItemIterator( request ); // --------- hasNext() returns false, only in seam ----------- while ( iter.hasNext() ) { ...... } Additional Info: I don't want to use the technique described here since the uploading client is curl. The HttpServletRequest is wrapped by org.jboss.seam.web.IdentityRequestWrapper Using the seam

    Read the article

  • Parse and display MIME multipart email on website

    - by aidan
    I have a raw email, (MIME multipart), and I want to display this on a website (e.g. in an iframe, with tabs for the HTML part and the plain text part, etc.). Are there any CPAN modules or Template::Toolkit plugins that I can use to help me achieve this? At the moment, it's looking like I'll have to parse the message with Email::MIME, then iterate over all the parts, and write a handler for all the different mime types. It's a long shot, but I'm wondering if anyone has done all this already? It's going to be a long and error prone process writing handlers if I attempt it myself. Thanks for any help.

    Read the article

  • Sending an image via POST Multipart (HTTPRequest)

    - by James Jeffery
    I'm trying to send an image to a server, using HTTP Post Multipart. Everything else is fine, I have all the boundrys set and stuff. But what do I have to do to the image before hand? Do I have to convert it to binary? Here is the header data from the header (using Fiddler). This is what I need to upload: -----------------------------7daea2aa40c80 Content-Disposition: form-data; name="pict"; filename="pic.jpeg" Content-Type: image/pjpeg <Binary here ... or at least I think it is> .. ?????JFIF?????????C? (lots more of this I removed) Any advice?

    Read the article

  • Parsing content-disposion header's filename in multipart/from-data

    - by Artyom
    Hello According to RFC, in multipart/form-data content-disposition header filename field receives as parameter HTTP quoted string - string between quites where character '\' can escape any other ascii character. Problem web browsers don't do it. IE6 sends: Content-Disposition: form-data; name="file"; filename="z:\tmp\test.txt" Instead of expected Content-Disposition: form-data; name="file"; filename="z:\\tmp\\test.txt" Which should be parsed as z:tmptest.txt according to rules instead of z:\tmp\test.txt. Firefox, Konqueror and Chrome don't escape " characters for example: Content-Disposition: form-data; name="file"; filename=""test".txt" Instead of expected Content-Disposition: form-data; name="file"; filename="\"test\".txt" So... how would you suggest to deal with this issue?

    Read the article

  • Apache HttpClient making multipart form post

    - by Russ
    I'm pretty green to HttpClient and I'm finding the lack of (and or blatantly incorrect) documentation extremely frustrating. I'm trying to implement the following post (listed below) with Apache Http Client, but have no idea how to actually do it. I'm going to bury myself in documentation for the next week, but perhaps more experienced HttpClient coders could get me an answer sooner. Post: Content-Type: multipart/form-data; boundary=---------------------------1294919323195 Content-Length: 502 -----------------------------1294919323195 Content-Disposition: form-data; name="number" 5555555555 -----------------------------1294919323195 Content-Disposition: form-data; name="clip" rickroll -----------------------------1294919323195 Content-Disposition: form-data; name="upload_file"; filename="" Content-Type: application/octet-stream -----------------------------1294919323195 Content-Disposition: form-data; name="tos" agree -----------------------------1294919323195--

    Read the article

  • Markdown to text/plain and text/html for multipart email

    - by fphilipe
    I’m looking for a solution to send DRY multipart emails in Rails. With DRY I mean that the content for the mail is only defined once. I’ve thought about some possible solutions but haven’t found any existing implementations. The solutions I’ve thought about are: load the text from I18n and apply Markdown for the html mail and apply Markdown with a special output type for the text mail where links are put in parenthesis after the link text bold, italic and other formatting that doesn't make sense are removed ordered and unordered lists are maintained generate only the html mail and convert that to text according to the above conditions Is there any available solution out there? Which one is probably the better way to do it?

    Read the article

  • How to replace a multipart message schema in a map without replacing the map

    - by BizTalkMama
    I have an orchestration map that maps two source messages into one destination message. When the schema for one of the source messages changes, I was hoping to be able to click on the input message part and select "Replace Schema" to refresh the schema for just the message part affected. Instead I can only replace the entire multipart message schema with the single message part schema. My only other option seems to be to generate a new map from the orchestration transform shape, but this means I have to recreate all the links in my map... Does anyone know of a more efficient way to update this type of schema?

    Read the article

  • How to set up dynamically Part in MultipartRequestEntity

    - by ee_vin
    Hello, I'm using commons-httpclient-3.1 inside my android application. And I would like to know if it possible to manipulate Part (org.apache.commons.httpclient.methods.multipart.Part) dynamically? Essentially adding new FilePart and new StringPart at runtime before sending the request. Every example I've found until now suppose that you know how many fields you are dealing with. Ex: File f = new File("/path/fileToUpload.txt"); PostMethod filePost = new PostMethod("http://host/some_path"); Part[] parts = { new StringPart("param_name", "value"), new FilePart(f.getName(), f) }; filePost.setRequestEntity( new MultipartRequestEntity(parts, filePost.getParams()) ); HttpClient client = new HttpClient(); int status = client.executeMethod(filePost); code from http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.html Android specific thread: http://groups.google.com/group/android-developers/browse_thread/thread/0f9e17bbaf50c5fc Thank you

    Read the article

  • Issue with multipart/form-data

    - by kbrin80
    I am not able to get values from both files and text input in a servlet when my form includes multipart/form-data. I am using the apache.commons.fileuploads for help with the uploads. Any suggestions. Also in the code below there are some things that I feel should be more efficient. Is there a better way to store these multiple files in a db. public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) { boolean promo = false; Database db = new Database(); Homepage hp = db.getHomePageContents(); String part = ParamUtils.getStringParameter(request, "part", ""); if(part.equals("verbage")) { String txtcontent = (String)request.getParameter("txtcontent"); String promoheader = (String)request.getParameter("promoheader"); String promosubheader = (String)request.getParameter("promosubheader"); hp.setBodyText(txtcontent); hp.setPromoHeader(promoheader); hp.setPromoSubHeader(promosubheader); System.err.println(txtcontent); } else { boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (!isMultipart) { } else { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List items = null; try { items = upload.parseRequest(request); //System.err.print(items); } catch (FileUploadException e) { e.printStackTrace(); } Iterator itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); if(item.getFieldName().equals("mainimg1")) { if(item.getName() !="") hp.setMainImg1(item.getName()); } if(item.getFieldName().equals("mainimg2")) { if(item.getName() !="") hp.setMainImg2(item.getName()); } if(item.getFieldName().equals("mainimg3")) { if(item.getName() !="") hp.setMainImg3(item.getName()); } if(item.getFieldName().equals("promoimg1")) { promo = true; if(item.getName() !="") { hp.setPromoImg1(item.getName()); try { File savedFile = new File("/Library/resin-4.0.1/webapps/ROOT/images/promoImg1.jpg"); item.write(savedFile); //System.err.print(items); } catch (Exception e) { System.err.println(e.getMessage()); } } } if(item.getFieldName().equals("promoimg2")) { if(item.getName() !="") { hp.setPromoImg2(item.getName()); try { File savedFile = new File("/Library/resin-4.0.1/webapps/ROOT/images/promoImg2.jpg"); item.write(savedFile); //System.err.print(items); } catch (Exception e) { System.err.println(e.getMessage()); } } } if(item.getFieldName().equals("promoimg3")) { if(item.getName() !="") { hp.setPromoImg3(item.getName()); try { File savedFile = new File("/Library/resin-4.0.1/webapps/ROOT/images/promoImg3.jpg"); item.write(savedFile); //System.err.print(items); } catch (Exception e) { System.err.println(e.getMessage()); } } } System.err.println("FNAME =" + item.getFieldName() + " : " + item.getName()); if (item.isFormField()) { } else { try { if(!promo) { String itemName = item.getName(); File savedFile = new File("/Library/resin-4.0.1/webapps/ROOT/images/"+itemName); item.write(savedFile); } //System.err.print(items); } catch (Exception e) { System.err.println(e.getMessage()); } } } } } db.updateHomePageContent(hp);

    Read the article

  • JavaFX: File upload to REST service / servlet fails because of missing boundary

    - by spa
    I'm trying to upload a file using JavaFX using the HttpRequest. For this purpose I have written the following function. function uploadFile(inputFile : File) : Void { // check file if (inputFile == null or not(inputFile.exists()) or inputFile.isDirectory()) { return; } def httpRequest : HttpRequest = HttpRequest { location: urlConverter.encodeURL("{serverUrl}"); source: new FileInputStream(inputFile) method: HttpRequest.POST headers: [ HttpHeader { name: HttpHeader.CONTENT_TYPE value: "multipart/form-data" } ] } httpRequest.start(); } On the server side, I am trying to handle the incoming data using the Apache Commons FileUpload API using a Jersey REST service. The code used to do this is a simple copy of the FileUpload tutorial on the Apache homepage. @Path("Upload") public class UploadService { public static final String RC_OK = "OK"; public static final String RC_ERROR = "ERROR"; @POST @Produces("text/plain") public String handleFileUpload(@Context HttpServletRequest request) { if (!ServletFileUpload.isMultipartContent(request)) { return RC_ERROR; } FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); List<FileItem> items = null; try { items = upload.parseRequest(request); } catch (FileUploadException e) { e.printStackTrace(); return RC_ERROR; } ... } } However, I get a exception at items = upload.parseRequest(request);: org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found I guess I have to add a manual boundary info to the InputStream. Is there any easy solution to do this? Or are there even other solutions?

    Read the article

  • php, curl , php curl , multipart/form-data , upload picture redirect

    - by Michael
    I'm trying to upload some pictures using php cURL on a classified ad website .I think that I set all the parameters properly but I see that there is a kind of redirect after I post the picture . The issue is that the url where I'm getting redirected gives 404 error instead to return the html that it does when I make the post with a normal browser . here is the php code that I have so far " $URL = "http://api.classistatic.com/api/image/upload"; $s = "PAD001"; $v = "2"; $n = "k"; $a = "1:a126581b8150ddc1337cabce28f2feb53849fd143bd6e42649f90175c0e023e3"; $u = "@/var/www/html/artwork/tmp/!BszBLV!EGk~$(KGrHqEOKicEvMi8HVg(BL5ZbWvs0g~~_1.JPG"; $htmlContent = $baseClass-processPicturerequest($URL, $s, $v, $b, $n, $a, $u); The log from server is as following : http://pastebin.com/gZqPgsFX

    Read the article

  • curl multipart/form-data help

    - by user253530
    Hi am trying to post some data on a website using CURL. The posting process has 3 steps. 1. enter a URL, submit and get to the 2nd step with some fields already completed 2. submit again, after you entered some more data and preview the form. 3. submit the final data. The problem is that after the second step, the form data looks like this POSTDATA =-----------------------------12249266671528 Content-Disposition: form-data; name="title" Filme 2010, filme 2009, filme noi, programe TV, program cinema, premiere cinema, trailere filme - CineMagia.ro -----------------------------12249266671528 Content-Disposition: form-data; name="category" 3 -----------------------------12249266671528 Content-Disposition: form-data; name="tags" filme, programe tv, program cinema -----------------------------12249266671528 Content-Disposition: form-data; name="bodytext" Filme 2010, filme 2009, filme noi, programe TV, program cinema, premiere cinema, trailere filme -----------------------------12249266671528 Content-Disposition: form-data; name="trackback" -----------------------------12249266671528 Content-Disposition: form-data; name="url" http://cinemagia.ro -----------------------------12249266671528 Content-Disposition: form-data; name="phase" 2 -----------------------------12249266671528 Content-Disposition: form-data; name="randkey" 9510520 -----------------------------12249266671528 Content-Disposition: form-data; name="id" 17753 -----------------------------12249266671528-- I am stuck trying to devise an algorithm that will generate this kind of POST data for the second step. Just to mention the URL of the form never changes. It is always: http://www.xxx.com/submit. There is only a hidden input called "phase" that changes according to the step i am currently on (phase = 1, phase = 2, phase = 3). Any help, be it either code, pseudo-code or just guidance would be greatly appreciated. My code so far: function postBlvsocialbookmarkingcom($curl,$vars) { extract($vars); $baseUrl = "http://www.blv-socialbookmarking.com/"; //step 1: login $curl->setRedirect(); $page = $curl->post ($baseUrl.'login.php?return=/index.php', array ('username' => $username, 'password' => $password, 'processlogin' => '1', 'return' => '/index.php')); if ($err = $curl->getError ()) { return $err; } //post step 1---- //get random key $page = $curl->post($baseUrl.'/submit', array()); $randomKey = explode('<input type="hidden" name="randkey" value="',$page); $randKey = explode('"',$randomKey[1]); //------------------------------------- $page = $curl->post($baseUrl.'/submit', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1')); if ($err = $curl->getError ()) { return $err; } //echo $page; // //post step 2 $page = $curl->post ($baseUrl.'/submit', array ('title' => $title, 'category'=>'1', 'tags' => $tags, 'bodytext' => $description, 'phase' => '2')); if ($err = $curl->getError ()) { return $err; } echo $page; //post step 3 $page = $curl->post ($baseUrl.'/submit', array ('phase' => '3')); if ($err = $curl->getError ()) { return $err; } echo $page; }

    Read the article

  • Sending multipart response for downloads in Zend Framework

    - by takeshin
    I'm sending files in action helper for downloads (in parts if needed) like this: ... $response->sendHeaders(); $chunksize = 1 * (1024 * 1024); $bytesSent = 0; if ($httpRange) { fseek($file, $range); } while(!feof($file) && (!connection_aborted() && ($bytesSent < $newLength)) ) { $buffer = fread($file, $chunksize); // $response->appendBody($buffer); // this would be better print($buffer); flush(); $bytesSent += strlen($buffer); } fclose($file); I suspect that better way would be to make use of $response object instead of print. Which is the recommended way to send big response objects using Zend Framework?

    Read the article

  • Ruby Oauth File upload/Multipart POST request

    - by Jonas Söderström
    Hi I've been looking at this for a couple of hours now and haven't found a solution. Is there a way to upload a file using OAuth-Ruby? When I send a normal request, everything works but adding a file as a parameter makes the signature invalid. Example: @access_token.post("http://.../imageresource", {:name=>"awesome cat"}) works great but gives me: <error> <message>images/POST: Request has neither file data nor a fileUrl from which to download data</message> </error> Any thoughts on this? Thanks,

    Read the article

  • android/rails multipart upload problem

    - by trioglobal
    My problem is that I try to upload an image and some text values to an rails server, and the text values end up as files, insted of just param values. How the post looks on the server Parameters: {"action"="create", "controller"="problems", "problem"={"lon"=#File:/tmp/RackMultipart20100404-598-8pi1vj-0, "photos_attributes"={"0"={"image"=#File:/tmp/RackMultipart20100404-598-pak6jk-0}}, "subject"=#File:/tmp/RackMultipart20100404-598-nje11p-0, "category_id"=#File:/tmp/RackMultipart20100404-598-ijy1oo-0, "lat"=#File:/tmp/RackMultipart20100404-598-1a7140w-0, "email"=#File:/tmp/RackMultipart20100404-598-1b7w6jp-0}} part of the android code try { File file = new File(Environment.getExternalStorageDirectory(), "FMS_photo.jpg"); HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://homepage.com/path"); FileBody bin = new FileBody(file); Charset chars = Charset.forName("UTF-8"); MultipartEntity reqEntity = new MultipartEntity(); //reqEntity.addPart("problem[subject]", subject); reqEntity.addPart("problem[photos_attributes][0][image]", bin); reqEntity.addPart("problem[category_id]", new StringBody("17", chars)); //.... post.setEntity(reqEntity); HttpResponse response = client.execute(post); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { resEntity.consumeContent(); } return true; } catch (Exception ex) { //Log.v(LOG_TAG, "Exception", ex); globalStatus = UPLOAD_ERROR; serverResponse = ""; return false; } finally { }

    Read the article

  • Multipart question: Mapping between xml and Json using xpath

    - by scope-creep
    This is a JSON mapping question from a json newbie. Currently i'm reading xml using xpath in C#, and the xpath are returning either the element or attribute node values, as is the schema's want. I want to write out some of the returned values into a json formatted file. I know i can faneigle the xpath expression to return the element or attribute names, so I can built the appropriate name/value json structure before serialization, but I was I'm wondering if their was some way of doing a mapping between the xml and json. The xml schema is fairly big, so potentially the mapping will be big, meaning a ton of cumbersom coding to make it work. Is their any way to automap somehow? I was planning to use json.net, which seems flexible enough, although their may be a better approach. Any help would be appreciated. Bob.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >