mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 13:50:20 +08:00
Drop old chunked upload API
This commit is contained in:
@@ -651,9 +651,6 @@ class FileToolParameter(ToolParameter):
|
||||
if re.match(r"^[\w-]+$", session_id) is None:
|
||||
raise ValueError("Invalid session id format.")
|
||||
local_filename = os.path.abspath(os.path.join(upload_store, session_id))
|
||||
if upload_store != trans.app.config.new_file_path and not os.path.exists(local_filename):
|
||||
# Fallback for old chunked API, remove in 22.05
|
||||
local_filename = os.path.abspath(os.path.join(trans.app.config.new_file_path, session_id))
|
||||
else:
|
||||
# handle nginx upload
|
||||
upload_store = trans.app.config.nginx_upload_store
|
||||
|
||||
@@ -2,14 +2,8 @@
|
||||
API operations for uploaded files in storage.
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from galaxy import exceptions
|
||||
from galaxy.web.framework.decorators import (
|
||||
expose_api_raw_anonymous,
|
||||
legacy_expose_api_anonymous,
|
||||
)
|
||||
from galaxy.web.framework.decorators import expose_api_raw_anonymous
|
||||
from . import BaseGalaxyAPIController
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -25,39 +19,3 @@ class UploadsAPIController(BaseGalaxyAPIController):
|
||||
"""
|
||||
# Internal endpoint, only purpose is to authenticate user, but may grow additional functionality in the future
|
||||
return None
|
||||
|
||||
@legacy_expose_api_anonymous
|
||||
def index(self, trans, **kwd):
|
||||
raise exceptions.NotImplemented("Listing uploads is not implemented.")
|
||||
|
||||
@legacy_expose_api_anonymous
|
||||
def create(self, trans, payload, **kwd):
|
||||
"""
|
||||
POST /api/uploads/
|
||||
"""
|
||||
session_id = payload.get("session_id")
|
||||
session_start = payload.get("session_start")
|
||||
session_chunk = payload.get("session_chunk")
|
||||
if re.match(r"^[\w-]+$", session_id) is None:
|
||||
raise exceptions.MessageException("Requires a session id.")
|
||||
if session_start is None:
|
||||
raise exceptions.MessageException("Requires a session start.")
|
||||
if not hasattr(session_chunk, "file"):
|
||||
raise exceptions.MessageException("Requires a session chunk.")
|
||||
target_file = os.path.join(trans.app.config.new_file_path, session_id)
|
||||
target_size = 0
|
||||
if os.path.exists(target_file):
|
||||
target_size = os.path.getsize(target_file)
|
||||
if session_start != target_size:
|
||||
raise exceptions.MessageException("Incorrect session start.")
|
||||
chunk_size = os.fstat(session_chunk.file.fileno()).st_size
|
||||
if chunk_size > trans.app.config.chunk_upload_size:
|
||||
raise exceptions.MessageException("Invalid chunk size.")
|
||||
with open(target_file, "ab") as f:
|
||||
while True:
|
||||
read_chunk = session_chunk.file.read(self.READ_CHUNK_SIZE)
|
||||
if not read_chunk:
|
||||
break
|
||||
f.write(read_chunk)
|
||||
session_chunk.file.close()
|
||||
return {"message": "Successful."}
|
||||
|
||||
Reference in New Issue
Block a user