Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get file size from S3 after upload + fix upload #4952

Merged
merged 5 commits into from May 14, 2024

Conversation

imsdu
Copy link
Contributor

@imsdu imsdu commented May 8, 2024

Fixes #4944

/**
* Allows to resolve an ''S'' to an ''A''
*/
trait Lens[S, A] {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code is dead

/**
* Convert the array of bytes to a string of the hexadecimal values
*/
def valueOf(value: Array[Byte]): String = value.map("%02x".format(_)).mkString
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Common shared utility method

final case object NotComputedDigest extends Digest {
override val computed: Boolean = false
}
final case object NoDigest extends Digest
Copy link
Contributor Author

@imsdu imsdu May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly different from the other one (NotComputedDigest) where we were expecting it to be computed in the future

/**
* Rejection returned when a file can not be saved because content-length is not provided
*/
final case object ContentLengthIsMissing
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing a put with a stream and asking for a checksum, it seems that the content length is needed

case class HeadObject(fileSize: Long, contentType: Option[ContentType], digest: Digest)

object HeadObject {
def apply(response: HeadObjectResponse): HeadObject = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart constructor to add more value to the class

http {
client {
parsing {
max-content-length="100g"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test with larger files

extraHeaders: Seq[HttpHeader] = jsonHeaders
)(assertResponse: (A, HttpResponse) => Assertion)(implicit um: FromEntityUnmarshaller[A]): IO[Assertion] = {
def buildClue(a: A, response: HttpResponse) =
def uploadFile(project: String, storage: String, file: FileInput, rev: Option[Int])(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the tests to do a general use of FileInput

@@ -309,4 +311,27 @@ class S3StorageSpec extends StorageSpec {
} yield assertion
}
}

"Uploading a large file" should {
"succeed" ignore {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored for now as it takes ~2min to complete
We may want to introduce a slow tag for those and still run them from time to time in a scheduled fashion
(there is at least another one for archives iirc)

@imsdu imsdu merged commit dbb4200 into BlueBrain:master May 14, 2024
7 checks passed
@imsdu imsdu deleted the 4944-get-size-from-s3-fix-upload branch May 14, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When uploading the file, the checksum and the size should be retrieved from a head request
2 participants