Workdocs does not recognize the Excel files as the files are pushed from S3 bucket and using S3 to Workdocs architecture


I have enabled microsoft enabled in workdocs but still I see strange behaviour with Amazon workdocs were it is not reading the file and cant edit it on Workdocs.

The file is pushed from S3 bucket which gets the file from another lambda function which creates and pushes the file to S3 bucket which is linked with workdocs.

When I upload the same file in the S3 bucket directly it goes to Workdocs and works fine only when the preprocessed file comes from lambda than only it doesn't work. I feel most possible the issue with how I push file to s3 bucket thecode must be something different or I dont know hat is the big problem. Please let me know

S3 to Workdocs article:

Lambda code to create and push the excel file to s3 bucket:

    bucket_name_output = 'sf-data'  -- sample name
    file_key_output = 'sf_check_daily_upload/ssot_dev.csv000'

    ########### SF check data read ############# 
    response_sf = s3.get_object(Bucket=bucket_name_output, Key=file_key_output)
    csv_content_sf = response_sf['Body'].read().decode('utf-8')
    df_sf = pd.read_csv(io.StringIO(csv_content_sf))
    df_sf.to_excel('/tmp/sf_check_data.xlsx', sheet_name='SF_check', index=False)
    s3 = boto3.client("s3")
    s3_resource = boto3.resource("s3")
    s3_resource.Bucket("carts-sf-s3toworkdocs-data-source").upload_file('/tmp/sf_check_data.xlsx', 'carts_sf_ssot_data/sf_check_data.xlsx')
asked a month ago136 views
2 Answers

May you please confirm that your Lambda function is able to upload the preprocessed file to S3? If not, may you please share the error that you are getting when you try to upload the document to S3.

profile pictureAWS
answered a month ago
  • I dont get any error. The file gets perfectly uploaded to the s3. Also from s3 it goes to Workdocs without any error and finally in Workdocs when I am expecting the .xlsx file to be Microsoft readable it doesnt work.


I was able to resolve the issue described below.

After doing few checks with the Workdocs response that I got in the code I got to know it was the issue there and after changing the parameter for Object type in the code to "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" I was able to get the file in workdocs as Excel readable and I resolved the issue.

The main issue was previously for the file uploaded in s3 the workdocs automatically took object type as the above shared but when it was coming from the previous lambda it was getting the object type as binary which was sending the file to workdocs as binary. Just chnaging the object type to hardcoded helped me.

answered a month ago
  • I am glad to know that you managed to find the cause of the issue and it is resolved.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions