-
Notifications
You must be signed in to change notification settings - Fork 162
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
Can't upload files from AWS S3 #612
Comments
Hi @arampetrosyann I'm unable to replicate your error using our sample app. Code snippet: const filename = "xero-dev.png";
const pathToUpload = path.resolve(__dirname, "../public/images/xero-dev.png");
const readStream = fs.createReadStream(pathToUpload);
const contentType = mime.lookup(filename);
const uploadFile = await xero.filesApi.uploadFile(req.session.activeTenant.tenantId, readStream, filename, contentType); Response body: { "name": "xero-dev.png", "mimeType": "image/png", "size": 34843, "createdDateUtc": "2022-11-07T21:53:13.8370000", "updatedDateUtc": "2022-11-07T21:53:13.8370000", "user": { "id": "96536500-45b9-4170-b4ad-40c180fb9f48", "name": "[email protected]", "firstName": "Rett", "lastName": "Behrens", "fullName": "Rett Behrens" }, "id": "a38238cf-d108-416b-8206-89655c7a8b2b", "folderId": "f8405741-5cbb-405f-9343-2cc221004843" } Can you please provide more information?
|
Hi @RettBehrens Code: const fileStream = s3
.getObject({
Bucket: file.bucket,
Key: file.externalKey,
})
.createReadStream()
const [fileName, mimeType] = this.constructor.processFileName(fileExp.name)
const res = await this.filesApi.uploadFile(
this.tenantId,
fileStream,
fileName,
fileName,
mimeType
) I'm using AWS S3. Version of SDK - 4.21.0 |
Is there any additional indication of where this error is originating? When testing in the sample app, the SDK error if no body present is Can you provide your app Client ID so I can check the logs on our side? |
@arampetrosyann checking in to see if you've resolved the issue on your end or if this remains ongoing? |
@RettBehrens no I couldn't resolve that. The error comes from response. Client ID - A2F4E2DB397C4107B2671C1FB4B14F27 |
Your request resulting in
My request resulting in
I see that your Allowed file types:
|
const [fileName, mimeType] = this.constructor.processFileName(fileExp.name)
const res = await this.filesApi.uploadFile(
this.tenantId,
fileStream,
fileName,
fileName,
mimeType,
{ headers: { 'Content-Type': mimeType } }
) Result is the same. Correlation ID - e02361e0-b055-47ea-ac38-166f50b132e2 |
The request header content type is correct, however, the request body is still showing const fileStream = s3
.getObject({
Bucket: file.bucket,
Key: file.externalKey,
ResponseContentType: 'image/jpeg',
})
.createReadStream() If the above works, can you specify content type when uploading to S3? |
That was inefficient. Correlation ID - 61c63e0d-f8ce-4a15-8595-a4b91f107549 I always recieve the same error message. Can I send a file with base64 format? |
From the dev team:
Additionally:
Based on the dev team feedback, I have a couple questions:
|
xero-node/src/gen/api/filesApi.ts
Line 1120 in a9c37e5
I'm getting an error when trying to upload a file. (Files API)
The error is -
{ type: 'Validation', title: 'Validation failure', detail: 'No file is was attached' }
Request body is missing in request options.
The text was updated successfully, but these errors were encountered: