Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Swift ios trying to upload file to s3 but file never gets uploaded

I am trying to upload a file to S3 using:

func uploadImage(with data: Data) {
        let expression = AWSS3TransferUtilityUploadExpression()
        expression.progressBlock = progressBlock

        transferUtility.uploadData(
            data,
            bucket: "MyBucket",
            key: "img.jpg",
            contentType: "image/jpeg",
            expression: expression,
            completionHandler: completionHandler).continueWith { (task) -> AnyObject! in
                if let error = task.error {
                    print("Error: \(error.localizedDescription)")
                    self.statusLabel.text = "Failed"
                }

                if let _ = task.result {
                    self.statusLabel.text = "Generating Upload File"
                    print("Upload Starting!")
                    // Do something with uploadTask.
                }

                return nil;
        }
    }


self.uploadImage(with: imageData)

I see this in my console: Upload Starting! But the file never gets uploaded

Bucket permissions:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::myBucket/*"
        }
    ]
}

oneClick_Cognito_MyUserUnauth_Role_xxxxxx policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "mobileanalytics:PutEvents",
                "cognito-sync:*",
                "s3:*"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

I get the error: Domain=com.amazonaws.AWSS3TransferUtilityErrorDomain Code=2

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

The problem was that my Cognito user was in us region, and my bucket was in eu.

over 4 years ago · Santiago Trujillo Denunciar

0

In your bucket permission, try adding permission for s3:PutObject

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda