Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle App Engine - Blobstore request working on production not in development
    primarykey
    data
    text
    <p>I'm using google app engine to develop an upload form to upload a csv file. The issue I'm currently having is that in a Development environment the request action is to being sent correctly.</p> <p>In the production environment the request action seems to work although the action is the same for both forms.</p> <p>E.g.</p> <p>Development</p> <pre><code> action="http://localhost:8080/_ah/upload/ag50cy1zY2gtcmVwb3J0c3IbCxIVX19CbG9iVXBsb2FkU2Vzc2lvbl9fGAEM" </code></pre> <p>Production action:</p> <pre><code> action="http://website.appspot.com/_ah/upload/AMmfu6Yer2BJaT_tW_fmc- PKvHaOHD3pnv5QH6o6d8XQQujbCWg5egbjf2sGxP5_cN6uAyvgDVOn8U40wLLXEvoQcrMDbHQQByJpTlamzBPz_8x8LN2UWKM/ALBNUaYAAAAAT1EmxMkvj7tiS9WAvYAWKPG1sN1DvmMk/" </code></pre> <p>When I investigate within the logs, the development server states the action is: "/ag50cy1zY2gtcmVwb3J0c3IbCxIVX19CbG9iVXBsb2FkU2Vzc2lvbl9fGAEM"</p> <p>Where as the Production logs state the action is: "/form" (as expected)</p> <p>The code for both is the same underneath as follows.</p> <p>file: upload.jsp</p> <pre><code> &lt;% request.getAttribute("message"); BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); %&gt; &lt;hr/&gt; &lt;p&gt;Upload a .csv file to the system.&lt;/p&gt; &lt;fieldset&gt; &lt;legend&gt;Upload File&lt;/legend&gt; &lt;form action="&lt;%= blobstoreService.createUploadUrl("/upload/form") %&gt;" method="post" enctype="multipart/form-data"&gt; &lt;label for="filename_1"&gt;File: &lt;/label&gt; &lt;input id="filename_1" type="file" id="filename_1" name="file" size="30" onchange="checkInput();" /&gt;&lt;br/&gt; &lt;br/&gt; &lt;input type="submit" id="submitBtn" value="Upload File" /&gt; &lt;/form&gt; &lt;/fieldset&gt; </code></pre> <p>file: controller.java</p> <pre><code> else if (action.equals("/form")) { Logger.getLogger(Controller3.class.getName()).log(Level.INFO, action); Map&lt;String, List&lt;BlobKey&gt;&gt; blobs = blobstoreService.getUploads(request); List&lt;BlobKey&gt; bkList = blobs.get("filename_1"); BlobKey blobKey = bkList.get(0); if (blobKey == null) { Logger.getLogger(Controller3.class.getName()).log(Level.WARNING, "Blob null"); response.sendRedirect("/"); } else { Logger.getLogger(Controller3.class.getName()).log(Level.WARNING, "Blob not null"); FileService fileService = FileServiceFactory.getFileService(); // Create a new Blob file with mime-type "text/plain" AppEngineFile file = fileService.getBlobFile(blobKey);// Again, different standard Java ways of reading from the channel. FileReadChannel readChannel = fileService.openReadChannel(file, false); Reader reader1 = new BufferedReader(Channels.newReader(readChannel, "UTF8")); char c = ','; CSVReader reader = new CSVReader(reader1, c); ArrayList&lt;ArrayList&lt;String&gt;&gt; results = reader.getResults(); ArrayList&lt;String&gt; columns = reader.getColumns(); request.setAttribute("maxColumns", columns); request.setAttribute("csvResults", results); //Remove the CSV file from the blobstore now we have used it. blobstoreService.delete(blobKey); this.getServletContext().setAttribute("csvUploadResults", results); } </code></pre> <p>The web.xml has been setup to to deal with the requests: /_ah/upload/<em>, /upload/</em>, /_ah/upload/upload/*</p> <p>I'm hoping there is a simple explaination (there probably is) why the code works in production but not in development.</p> <p>Any assistance will be of great help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload