Rameshwar Bhaskar
08/01/2023, 11:26 AMfunction index( event, rc, prc ){
if (structKeyExists(rc, "image") ) {
var uploadedImage = fileUpload( getTempDirectory(), "image", "image/jpeg,image/png,image/gif", "MakeUnique" );
fileNameWithoutSpace = replace(uploadedImage.clientfilename, " ", "_")
var fileName = fileNameWithoutSpace & "_" &createUUID()& "." & uploadedImage.clientfileext;
var folderName = "coldbox";
var fileNameToUpload = folderName & "/" & fileName;
var tes = s3sdk.putObject(
'Bucket': s3sdk.getDefaultBucketName(),
'uri':fileNameToUpload,
'Body': uploadedImage,
'ACL': 'public-read',
'ContentType': uploadedImage.contenttype,
'md5':'auto'
);
var imageUrl = "https://#s3sdk.getDefaultBucketName()#.<http://s3.amazonaws.com/|s3.amazonaws.com/>" & fileNameToUpload;
event.getResponse().addMessage( "Submitted successfully" ).setData(imageUrl);
} else {
event.getResponse().addMessage( "Failed" ).setError(true);
}
}
Everything goes successfully but the error is i can able to see the image file that i've uploaded
the response as follows
{
"data": "<https://srijaneducation.s3.amazonaws.com/coldbox/OIG.cLIuBy9TZIHQ4cg2cHnJ_BC68F717-700B-424D-AB6273104A4B08D8.jpg>",
"error": false,
"pagination": {
"totalPages": 1,
"maxRows": 0,
"offset": 0,
"page": 1,
"totalRecords": 0
},
"messages": [
"Welcome to my ColdBox RESTFul Service"
]
}
the image response is <https://srijaneducation.s3.amazonaws.com/coldbox/OIG.cLIuBy9TZIHQ4cg2cHnJ_BC68F717-700B-424D-AB6273104A4B08D8.jpg>
what's the exact solution for italiaspooryorik
aliaspooryorik
Rameshwar Bhaskar
08/01/2023, 1:13 PMaliaspooryorik
Rameshwar Bhaskar
08/01/2023, 1:55 PMRameshwar Bhaskar
08/01/2023, 2:01 PMaliaspooryorik
Rameshwar Bhaskar
08/01/2023, 2:06 PMhttps://srijaneducation.s3.ap-south-1.amazonaws.com/coldbox/OIG.cLIuBy9TZIHQ4cg2cHnJ_AC86626B-4B67-4DCB-AE0BEA7388C01EDB.jpg▾
aliaspooryorik
Rameshwar Bhaskar
08/01/2023, 2:07 PMRameshwar Bhaskar
08/01/2023, 2:08 PMaliaspooryorik
aliaspooryorik
aliaspooryorik
uploadedImage into putObject without checking what uploadedImage is.aliaspooryorik
Patrick
08/01/2023, 2:12 PMaddMessage . All this being said with the assumption that your putObject IS successfully putting that on the s3 bucket per convo above.aliaspooryorik
Rameshwar Bhaskar
08/01/2023, 2:14 PMaliaspooryorik
aliaspooryorik
aliaspooryorik
Rameshwar Bhaskar
08/01/2023, 2:18 PMaliaspooryorik
writedump will help a lot to understand what sort of data you have (just as you would use console.log in Javascript). As you are using ColdBox then also well worth looking into the debug() methods in LogBox.Rameshwar Bhaskar
08/01/2023, 2:59 PMhttps://srijaneducation.s3.ap-south-1.amazonaws.com/coldbox/OIG.cLIuBy9TZIHQ4cg2cHnJ_EE275BC3-1DD7-4419-B6D6DB6A310E9268.jpg▾