I have created a DMG file and need to distribute it with a public link. Please note that the dmg file opens properly on all the macs if I transfer it through commandline scp (OpenSSH).
However, if I upload the same DMG file to Google Drive or AWS S3, and then redownload it to the same mac, it says the app has been damaged.
What attributes change when the file is uploaded to Google Drive or AWS S3?
Update-1
Working DMG attibutes:
- com.apple.FinderInfo
- com.apple.diskimages.recentcksum
- com.apple.lastuseddate#PS
- com.apple.macl
Non Working DMG attributes:
- com.apple.diskimages.fsck
- com.apple.diskimages.recentcksum
- com.apple.macl
- com.apple.metadata:kMDItemWhereFroms
- com.apple.quarantine
Tried removing all attibutes by using xattr -cr . Yet the working dmg works, and the non-working dmg doesn't work

MacOS sometimes adds the quarantine attribute if it doesn't trusts the app even though it is signed.
Check it by running
xattr /path/to/app.appin the terminalif it contains the 'com.apple.quarantine' attribute, then probably you will get the above error in a dialogue-box.
To remove the attribute, run the below command before opening your DMG/App
To completely avoid this hassle, the app must be notarized.
References: