Kris
Kris

Reputation: 1556

How to upload file by giving a path in url

Is it possible to upload a file in Play! framework only by giving a path in url? For example I would like to call:

www.mywebsite.com/upload_PATH

It's for me quite important, because I would like to upload and process a lot of data. Selecting manually 1000 files is too much time consuming and I want to write a program which will make it for me :-) I'm using Play with Java.

Upvotes: 0

Views: 809

Answers (2)

biesior
biesior

Reputation: 55798

As nico_ekito wrote www.mywebsite.com/upload_from_local_path won't work

In case of huge amount of files you can create temporary folder on the distant server and upload your files with FTP. Then in your app you'll need only action for post-upload processing, ie. it can check if file is valid and move it to calculated destination and register in database if required.

Other possibility is using some flash/ajax multi uploader for an example swfupload (don't know it, it's just first hit from the search engine). This approach will be better if you are going give the upload possibility to people who you don't want to give any FTP access.

Finally you can mix the solutions -> use uploader instead of FTP and later post-process new items remotely.

Upvotes: 0

ndeverge
ndeverge

Reputation: 21564

If upload_PATH is a local file path on your system, it is not a good way to go.

You should write a Play action where you can upload a file, as it is done in this example.

Then, you should write a HTTP client (started by a main Java method) which go through your files and upload then calling the Play! action. You can use the httpclient Apache library for writing the client part.

Upvotes: 3

Related Questions