Created
April 23, 2023 15:02
-
-
Save itarocha/dbf36e36994058fae5c69d3d4808256b to your computer and use it in GitHub Desktop.
Upload multipart from aws json event and reposting to spring boot rest application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"resource": "/create", | |
"path": "/create", | |
"httpMethod": "POST", | |
"headers": { | |
"Accept": "*/*", | |
"CloudFront-Forwarded-Proto": "https", | |
"CloudFront-Is-Desktop-Viewer": true, | |
"CloudFront-Is-Mobile-Viewer": false, | |
"CloudFront-Is-SmartTV-Viewer": false, | |
"CloudFront-Is-Tablet-Viewer": false, | |
"CloudFront-Viewer-ASN": "53006", | |
"CloudFront-Viewer-Country": "BR", | |
"content-type": "multipart/form-data; boundary=X-INSOMNIA-BOUNDARY", | |
"Host": "zz1myt8fmb.execute-api.sa-east-1.amazonaws.com", | |
"User-Agent": "insomnia/2023.1.0", | |
"Via": "2.0 6f6cfad7cbccfc294ba741d88889e5f6.cloudfront.net (CloudFront)", | |
"X-Amz-Cf-Id": "6-mVyvqSUhZ36XpY9U6JYUKo9ejZExBHujpC9CnIx1bcjx-z5aW-Rg==", | |
"X-Amzn-Trace-Id": "Root=1-6440b007-4f2129577c3b3f033b83758e", | |
"X-Forwarded-For": "191.54.174.165, 130.176.164.190", | |
"X-Forwarded-Port": "443", | |
"X-Forwarded-Proto": "https" | |
}, | |
"multiValueHeaders": { | |
"Accept": [ | |
"*/*" | |
], | |
"CloudFront-Forwarded-Proto": [ | |
"https" | |
], | |
"CloudFront-Is-Desktop-Viewer": [ | |
true | |
], | |
"CloudFront-Is-Mobile-Viewer": [ | |
false | |
], | |
"CloudFront-Is-SmartTV-Viewer": [ | |
false | |
], | |
"CloudFront-Is-Tablet-Viewer": [ | |
false | |
], | |
"CloudFront-Viewer-ASN": [ | |
"53006" | |
], | |
"CloudFront-Viewer-Country": [ | |
"BR" | |
], | |
"content-type": [ | |
"multipart/form-data; boundary=X-INSOMNIA-BOUNDARY" | |
], | |
"Host": [ | |
"zz1myt8fmb.execute-api.sa-east-1.amazonaws.com" | |
], | |
"User-Agent": [ | |
"insomnia/2023.1.0" | |
], | |
"Via": [ | |
"2.0 6f6cfad7cbccfc294ba741d88889e5f6.cloudfront.net (CloudFront)" | |
], | |
"X-Amz-Cf-Id": [ | |
"6-mVyvqSUhZ36XpY9U6JYUKo9ejZExBHujpC9CnIx1bcjx-z5aW-Rg==" | |
], | |
"X-Amzn-Trace-Id": [ | |
"Root=1-6440b007-4f2129577c3b3f033b83758e" | |
], | |
"X-Forwarded-For": [ | |
"191.54.174.165, 130.176.164.190" | |
], | |
"X-Forwarded-Port": [ | |
"443" | |
], | |
"X-Forwarded-Proto": [ | |
"https" | |
] | |
}, | |
"queryStringParameters": null, | |
"multiValueQueryStringParameters": null, | |
"pathParameters": null, | |
"stageVariables": null, | |
"requestContext": { | |
"resourceId": "7ow0pa", | |
"resourcePath": "/create", | |
"httpMethod": "POST", | |
"extendedRequestId": "DqBxKGhTGjQFupA=", | |
"requestTime": "20/Apr/2023:03:22:47 +0000", | |
"path": "/Prod/create", | |
"accountId": "085466734908", | |
"protocol": "HTTP/1.1", | |
"stage": "Prod", | |
"domainPrefix": "zz1myt8fmb", | |
"requestTimeEpoch": 1681960967182, | |
"requestId": "10173d9b-402e-4cf2-8de6-7211b1a787f9", | |
"identity": { | |
"cognitoIdentityPoolId": null, | |
"accountId": null, | |
"cognitoIdentityId": null, | |
"caller": null, | |
"sourceIp": "191.54.174.165", | |
"principalOrgId": null, | |
"accessKey": null, | |
"cognitoAuthenticationType": null, | |
"cognitoAuthenticationProvider": null, | |
"userArn": null, | |
"userAgent": "insomnia/2023.1.0", | |
"user": null | |
}, | |
"domainName": "zz1myt8fmb.execute-api.sa-east-1.amazonaws.com", | |
"apiId": "zz1myt8fmb" | |
}, | |
"body": "LS1YLUlOU09NTklBLUJPVU5EQVJZDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWR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JAAAAAAAAAAAAAAAAADgAAAAAAAAAAABAAAABpBAAAeGwvd29ya3NoZWV0cy9QSwECFAAUAAAACACHTuJAmicSdRwFAABEDwAAGAAAAAAAAAABACAAAACVBAAAeGwvd29ya3NoZWV0cy9zaGVldDEueG1sUEsFBgAAAAARABEABwQAAHMhAAAAAA0KLS1YLUlOU09NTklBLUJPVU5EQVJZLS0NCg==", | |
"isBase64Encoded": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import io | |
import base64 | |
import uuid | |
import requests | |
from multipart import MultipartParser, MultipartPart | |
tipos = { | |
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx", | |
"application/vnd.ms-excel": "xls", | |
"application/json": "json", | |
} | |
def build_part(part: MultipartPart): | |
tipo = tipos.get(part.content_type) | |
if tipo: | |
save_to_file(part, tipo) | |
# files = ('file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel')) | |
return part.name, (part.name, part.raw, part.content_type) # deve ser tuple, não dict! | |
def save_to_file(part: MultipartPart, extensao): | |
nomearquivo = str(uuid.uuid1()) | |
filename = './arquivos/' + nomearquivo + '.' + extensao | |
with open(filename, 'wb') as fd: | |
fd.write(part.raw) | |
def describe_part(part: MultipartPart): | |
# print(part.value) | |
print("***** Conteúdo:") | |
print(f'part.name: "{part.name}"') | |
print(f'part.file: "{part.file}"') | |
print(f'part.content_type: "{part.content_type}"') | |
print(f'part.charset: "{part.charset}"') | |
print(f'part.size: {part.size} bytes') | |
print(f'part.options: "{part.options}"') | |
print(f'part.headers: {part.headers}') | |
# part.save_as(part.name + ".bin") | |
# print(part.value) | |
if __name__ == "__main__": | |
with open('event_multipart.json') as f: | |
data = f.read() | |
event = json.loads(data) | |
multipart_data = event.get("body") | |
decoded = base64.b64decode(multipart_data) | |
content_type = event['headers']['content-type'] | |
boundary = content_type.split(";")[1].split("=")[1].encode('utf-8') | |
parts = MultipartParser(io.BytesIO(decoded), boundary) | |
multiple_files = [] | |
for part in parts: | |
multiple_files.append(build_part(part)) | |
describe_part(part) # apenas descritivo | |
url = 'http://localhost:8080/arquivo/upload' | |
headers = {'x-itamar-correlationID': '202314887'} | |
r = requests.post(url, headers=headers, files=multiple_files) | |
# 'Content-Type': 'multipart/form-data; boundary=3131623adb2043caaeb5538cc7aa0b3a', | |
print(f'retorno: {r.status_code}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.multipart.controller; | |
import lombok.SneakyThrows; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.web.bind.annotation.*; | |
import org.springframework.web.multipart.MultipartFile; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.util.UUID; | |
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; | |
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; | |
@RestController | |
@RequestMapping("/arquivo") | |
public class MultipartController { | |
@PostMapping(consumes = {MULTIPART_FORM_DATA_VALUE, APPLICATION_JSON_VALUE}, path = "/upload") | |
@ResponseStatus(HttpStatus.CREATED) | |
public void upload(@RequestHeader(name = "x-itamar-correlationID") String correlationId, | |
@RequestPart(name = "arquivo") MultipartFile arquivo, | |
@RequestPart(name = "cliente") ClienteRequest clienteRequest){ | |
System.out.println(arquivo.getContentType()); | |
System.out.println(arquivo.getOriginalFilename()); | |
System.out.println(clienteRequest.getId()); | |
System.out.println(clienteRequest.getNome()); | |
saveFile(arquivo); | |
} | |
@SneakyThrows | |
void saveFile(MultipartFile file){ | |
String fileName = UUID.randomUUID().toString(); | |
File convFile = new File("/home/itamar/projetos_python/sam-app-hello/interno/arquivos/"+fileName); | |
try { | |
convFile.createNewFile(); | |
FileOutputStream fos = new FileOutputStream(convFile); | |
fos.write(file.getBytes()); | |
fos.close(); //IOUtils.closeQuietly(fos); | |
} catch (IOException e) { | |
convFile = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment