carloea2 commented on code in PR #4136:
URL: https://github.com/apache/texera/pull/4136#discussion_r2658780436
##########
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala:
##########
@@ -639,139 +643,103 @@ class DatasetResource {
@QueryParam("type") operationType: String,
@QueryParam("ownerEmail") ownerEmail: String,
@QueryParam("datasetName") datasetName: String,
- @QueryParam("filePath") encodedUrl: String,
- @QueryParam("uploadId") uploadId: Optional[String],
+ @QueryParam("filePath") filePath: String,
@QueryParam("numParts") numParts: Optional[Integer],
- payload: Map[
- String,
- Any
- ], // Expecting {"parts": [...], "physicalAddress": "s3://bucket/path"}
@Auth user: SessionUser
): Response = {
val uid = user.getUid
+ val dataset: Dataset = getDatasetBy(ownerEmail, datasetName)
+
+ operationType.toLowerCase match {
+ case "init" => initMultipartUpload(dataset.getDid, filePath, numParts,
uid)
+ case "finish" => finishMultipartUpload(dataset.getDid, filePath, uid)
+ case "abort" => abortMultipartUpload(dataset.getDid, filePath, uid)
+ case _ =>
+ throw new BadRequestException("Invalid type parameter. Use 'init',
'finish', or 'abort'.")
+ }
+ }
- withTransaction(context) { ctx =>
- val dataset = context
- .select(DATASET.fields: _*)
- .from(DATASET)
- .leftJoin(USER)
- .on(USER.UID.eq(DATASET.OWNER_UID))
- .where(USER.EMAIL.eq(ownerEmail))
- .and(DATASET.NAME.eq(datasetName))
- .fetchOneInto(classOf[Dataset])
- if (dataset == null || !userHasWriteAccess(ctx, dataset.getDid, uid)) {
- throw new ForbiddenException(ERR_USER_HAS_NO_ACCESS_TO_DATASET_MESSAGE)
- }
+ @POST
+ @RolesAllowed(Array("REGULAR", "ADMIN"))
+ @Path("/multipart-upload/part")
+ @Consumes(Array(MediaType.APPLICATION_OCTET_STREAM))
+ def uploadPart(
+ @QueryParam("ownerEmail") ownerEmail: String,
Review Comment:
I think the simplest approach is to keep it as it is, since getting the did
in frontend will require an additional step in the frontend which we can save
if we do it by using dataset name in the backend as it is now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]