Skip to content
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

Files uploaded to S3 external storage given 'Content-type: application/octet-stream', always #19487

Closed
RealOrangeOne opened this issue Feb 14, 2020 · 4 comments · Fixed by #26575
Labels
1. to develop Accepted and waiting to be taken care of bug feature: external storage

Comments

@RealOrangeOne
Copy link

Steps to reproduce

  1. Create an S3-backed external storage mount
  2. Copy an existing file into the newly created mount

Expected behaviour

Uploaded file is given a relevant content-type, based on extension or MIME

Actual behaviour

File is given application/octet-stream

image

(The same file uploaded through the S3 web UI is given image/png correctly.

Server configuration

Operating system: Ubuntu 18.04

Web server: NGINX

Database: MariaDB

PHP version: 7.3, I think

Nextcloud version: (see Nextcloud admin page) 18.0.1 (issue also present on 18.0.0)

Updated from an older Nextcloud/ownCloud or fresh install: Updated from 18.0.0

Where did you install Nextcloud from: https://hub.docker.com/r/linuxserver/nextcloud

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.4.0
  - activity: 2.11.0
  - cloud_federation_api: 1.1.0
  - comments: 1.8.0
  - dav: 1.14.0
  - federatedfilesharing: 1.8.0
  - federation: 1.8.0
  - files: 1.13.1
  - files_external: 1.9.0
  - files_markdown: 2.2.0
  - files_pdfviewer: 1.7.0
  - files_rightclick: 0.15.2
  - files_sharing: 1.10.1
  - files_texteditor: 2.10.0
  - files_trashbin: 1.8.0
  - files_versions: 1.11.0
  - files_videoplayer: 1.7.0
  - firstrunwizard: 2.7.0
  - logreader: 2.3.0
  - lookup_server_connector: 1.6.0
  - nextcloud_announcements: 1.7.0
  - notifications: 2.6.0
  - oauth2: 1.6.0
  - onlyoffice: 4.1.4
  - password_policy: 1.8.0
  - photos: 1.0.0
  - privacy: 1.2.0
  - provisioning_api: 1.8.0
  - recommendations: 0.6.0
  - serverinfo: 1.8.0
  - settings: 1.0.0
  - sharebymail: 1.8.0
  - support: 1.1.0
  - survey_client: 1.6.0
  - systemtags: 1.8.0
  - tasks: 0.11.3
  - theming: 1.9.0
  - twofactor_backupcodes: 1.7.0
  - twofactor_totp: 4.1.2
  - updatenotification: 1.8.0
  - viewer: 1.2.0
  - workflowengine: 2.0.0
Disabled:
  - admin_audit
  - encryption
  - text
  - user_ldap

Nextcloud configuration:

Config report
{
    "system": {
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 0
        },
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
           **********
        ],
        "dbtype": "mysql",
        "version": "18.0.1.3",
        "overwrite.cli.url": "********",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "twofactor_enforced": "false",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "updater.secret": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "loglevel": 2
    }
}

Are you using external storage, if yes which one: local/smb/sftp/... S3

Are you using encryption: no

Are you using an external user-backend, if yes which one: No

Client configuration

Browser: Firefox

Operating system: Arch Linux

@RealOrangeOne RealOrangeOne added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Feb 14, 2020
@kesselb kesselb added 1. to develop Accepted and waiting to be taken care of feature: external storage 18-feedback and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Apr 3, 2020
@kesselb
Copy link
Contributor

kesselb commented Apr 3, 2020

https://github.com/nextcloud/3rdparty/blob/75fb4ab5bd03a59d6039dd376095e106c504bff0/aws/aws-sdk-php/src/S3/MultipartUploader.php#L141-L144

S3 SDK tries to detect the mime type by the extension. Unfortunately the uri is callback:// and the default application/octet-stream.

$uploader = new MultipartUploader($this->getConnection(), $countStream, [
'bucket' => $this->bucket,
'key' => $urn,
'part_size' => S3_UPLOAD_PART_SIZE
]);

			'params' => [
				'ContentType' => mimetype_from_filename($urn),
			]

I tried to set the content type at a earlier stage where the original filename is still available but somehow the information is lost 😞

@mipapo
Copy link

mipapo commented Jun 15, 2020

Really annoying :/ Would be great if that would get fixed.

@despens
Copy link

despens commented Jan 26, 2021

Would it be sufficient to change $uri to contain the name of the file in question?

@arthursp
Copy link

arthursp commented Apr 1, 2021

Look here :

https://docs.aws.amazon.com/aws-sdk-php/v3/api/function-GuzzleHttp.Psr7.mimetype_from_filename.html

the function is deprecated, maybe there is a link to ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug feature: external storage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants