Skip to content
Snippets Groups Projects
Commit 69b675cc authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Change plugin download

parent e17e9eed
No related branches found
No related tags found
No related merge requests found
ABC
\ No newline at end of file
......@@ -13,7 +13,7 @@ import de.tobias.playpad.model.account.{Account, Session}
import de.tobias.playpad.model.plugin.Plugin
import de.tobias.playpad.server.SqlHelper
import de.tobias.playpad.server.account._
import de.tobias.playpad.server.plugin.{PluginGet, PluginList}
import de.tobias.playpad.server.plugin.{PluginGet, PluginList, PluginRawGet}
import de.tobias.playpad.server.project.sync.ProjectSyncHandler
import de.tobias.playpad.server.project.{ProjectDelete, ProjectGet, ProjectList, ProjectPost}
import de.tobias.playpad.transformer.JsonTransformer
......@@ -82,9 +82,6 @@ object PlayPadServer extends App {
port(settings.server_port)
threadPool(8, 2, 60 * 60 * 1000)
val externalPath = Paths.get(settings.download_folder).toAbsolutePath.toString
externalStaticFileLocation(externalPath)
if (settings.server_secure) {
secure(settings.server_keystore_path, settings.server_keystore_password, null, null)
}
......@@ -102,6 +99,7 @@ object PlayPadServer extends App {
// Plugins
get("/plugins/:id", new PluginGet(pluginDao), transformer)
get("/plugins/raw/:id", new PluginRawGet(pluginDao, settings))
get("/plugins", new PluginList(pluginDao), transformer)
// Account
......
package de.tobias.playpad.server.plugin
import java.nio.file.{Files, Paths}
import com.google.gson.Gson
import com.j256.ormlite.dao.Dao
import de.tobias.playpad.model.plugin.Plugin
import de.tobias.playpad.server.{Result, Status}
import de.tobias.playpad.utils.settings.Settings
import spark.{Request, Response, Route}
/**
* Created by tobias on 05.02.17.
*/
class PluginRawGet(dao: Dao[Plugin, Int], settings: Settings) extends Route {
val gson = new Gson()
override def handle(request: Request, response: Response): AnyRef = {
val plugin = dao.queryForId(request.params(":id").toInt)
if (plugin == null) {
return new Result(Status.ERROR, "Bad request")
}
val path = Paths.get(settings.download_folder, plugin.path)
Files.readAllBytes(path)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment