Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Alpakka multi part upload does not work with s3mock #61

Closed
mishamo opened this issue Aug 4, 2017 · 0 comments · Fixed by #64
Closed

Alpakka multi part upload does not work with s3mock #61

mishamo opened this issue Aug 4, 2017 · 0 comments · Fixed by #64

Comments

@mishamo
Copy link

mishamo commented Aug 4, 2017

Attempting a multi-upload with alpakka results in Unsupported Content-Type, supported: application/octet-stream. This is likely caused by the returned content type from s3mock being plain/text for the InitiateMultiUpload request.

Test to reproduce issue:

feature("Alpakka") {
    scenario("Fails on multi part upload with s3mock") {

      implicit val inMemorySystem = ActorSystem.create("some-system", configFor("localhost", 8001))
      implicit val inMemoryMat = ActorMaterializer()(inMemorySystem)

      val api = new S3Mock(8001, new FileProvider("/tmp/s3"))(inMemorySystem)
      api.start

      val endpoint = new EndpointConfiguration(s"http://localhost:8001", "eu-west-1")
      val client = AmazonS3ClientBuilder.standard()
        .withPathStyleAccessEnabled(true)
        .withCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()))
        .withEndpointConfiguration(endpoint)
        .build()

      client.createBucket("test-bucket")

      val inMemoryBasedAlpakkaClient = S3Client(BasicCredentials("foo", "bar"), "us-east-1")(inMemorySystem, inMemoryMat)

      val eventualResult: Future[MultipartUploadResult] = Source.single(ByteString("test-content"))
        .runWith(inMemoryBasedAlpakkaClient.multipartUpload("test-bucket", "test-key"))

      Await.result(eventualResult, 10 seconds)
    }
  }


  def configFor(host: String, port: Int): Config = {
    ConfigFactory.parseMap(Map(
      "akka.stream.alpakka.s3.proxy.host" -> host,
      "akka.stream.alpakka.s3.proxy.port" -> port,
      "akka.stream.alpakka.s3.proxy.secure" -> false,
      "akka.stream.alpakka.s3.path-style-access" -> true
    ).asJava)

  }

Output:

[2017-08-04 11:43:57,926] activity-fun-test INFO  [some-system-akka.actor.default-dispatcher-16] i.f.s.route.PutObjectMultipartStart - multipart upload start to test-bucket/test-key
[2017-08-04 11:43:57,932] activity-fun-test DEBUG [some-system-akka.actor.default-dispatcher-16] i.f.s3mock.provider.FileProvider - starting multipart upload for s3://test-bucket/test-key

Unsupported Content-Type, supported: application/octet-stream
akka.http.scaladsl.unmarshalling.Unmarshaller$UnsupportedContentTypeException: Unsupported Content-Type, supported: application/octet-stream
	at akka.http.scaladsl.unmarshalling.Unmarshaller$UnsupportedContentTypeException$.apply(Unmarshaller.scala:158)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$EnhancedFromEntityUnmarshaller$$anonfun$forContentTypes$extension$1$$anonfun$apply$24$$anonfun$apply$25.apply(Unmarshaller.scala:114)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$EnhancedFromEntityUnmarshaller$$anonfun$forContentTypes$extension$1$$anonfun$apply$24$$anonfun$apply$25.apply(Unmarshaller.scala:111)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anon$1.apply(Unmarshaller.scala:58)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$EnhancedUnmarshaller$$anonfun$mapWithInput$extension$1$$anonfun$apply$18$$anonfun$apply$19.apply(Unmarshaller.scala:91)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$EnhancedUnmarshaller$$anonfun$mapWithInput$extension$1$$anonfun$apply$18$$anonfun$apply$19.apply(Unmarshaller.scala:91)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anon$1.apply(Unmarshaller.scala:58)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anonfun$transform$1$$anonfun$apply$2$$anonfun$apply$3.apply(Unmarshaller.scala:23)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anonfun$transform$1$$anonfun$apply$2$$anonfun$apply$3.apply(Unmarshaller.scala:23)
	at akka.http.scaladsl.unmarshalling.Unmarshaller$$anon$1.apply(Unmarshaller.scala:58)
	at akka.http.scaladsl.unmarshalling.Unmarshal.to(Unmarshal.scala:25)
	at akka.stream.alpakka.s3.impl.S3Stream$$anonfun$akka$stream$alpakka$s3$impl$S3Stream$$initiateMultipartUpload$1.apply(S3Stream.scala:130)
	at akka.stream.alpakka.s3.impl.S3Stream$$anonfun$akka$stream$alpakka$s3$impl$S3Stream$$initiateMultipartUpload$1.apply(S3Stream.scala:128)
	at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
	at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
	at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
	at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
	at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
	at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:38)
	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:43)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant