Forums Register Login

uploading text files

+Pie Number of slices to send: Send
Its my test task for job junior java can you help me how i must do that i cant understand what i must do upload file or what

As a Product Owner i would like to have Servlet WEB API that will allow me to query/filter
information from text files over web so that
- Any person would have access to file without uploading it on local box
- I can do basic query/filter operations online without using text editor or grep/awk/..
API should have following query params:
- limit: integer which represents max number of chars in text that API should return. If
parameter is blank or missing return max 10000 chars.
- q: string which represents text to search in file, i.e. if it q=java - API should return all
strings which equals to ‘java’ or containing it. If q is blank or missing - API should return
all text from file

Example of API call/response:
/somePath?q=Java&limit=1000&length=5&includeMetaData=true
Such call should return all strings that contains ‘Java’ with length <= 5 with total length <=
1000. Additionally metadata will be included.
Example JSON response:
{
"text":[
"Java",
"JavaC"
],
"metaData":{
"fileName":"javaLangSpec.txt",
"fileSize":"900KB",
"fileCreationDate":"January 23, 1996 at 12: 52PM"
}


1
+Pie Number of slices to send: Send
@artem, Hello.
Obviously, I cannot post a solution to this. However, I may be able to help. And please consider my response carefully, because I am not in your shoes: I have not seen the assignment, or talked with the person. Maybe my interpretation is off a bit. But I will but in 2 cents, because we have had debates at my organization, for years, about whether something like (what I think this) is, should even be done. Here goes.

I think the really confusing, single word here, is "uploading". This is phrased as "uploading it to local box". If that had been phrased, "any person would have access without downloading it to local box", would you be at all confused? When you visit a site and want to get something locally, like a nice image, do you ever "upload it to your local computer"?

Now, think: why would anyone need a servlet like this? Hint: there are two machines involved, separated by miles of space, talking over a network, with very different capabilities (local desktop with limited space and CPU, and remote server with lots of memory and storage and fast CPU(s)).

Finally, a decent place to work would likely allow you to ask questions, and get clarification. This is Saturday after Christmas, so nobody is in, but you should be able to ask at some point. And if not, I think you are on the right track reading posts here at Code Ranch. Reading about technical things, where knowledgeable people post solutions, etc., can also "build intuition".
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 711 times.
Similar Threads
FileUpload with Orion Package
How to get open or save dialog in struts.
Issue in uploading a file using Java program to server- server response gives [Content-Length] => 0
Problem with code after first execution
write the contents that we read from a file to a textbox.
Thread Boost feature
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:28:22.