0

We have a client where we implement the solution in AWS with tridion 2013. We have SVG implementation by using custom multimedia types (https://docs.sdl.com/LiveContent/content/en-US/SDL%20Web-v5/GUID-C171DEE7-0F1F-45EF-ACD6-7A9C5498925C ) . So, when you add a svg content, tridion is configured to set the MIME type as image/svg+xml. Having said that, when the content is uploaded into S3 bucket of AWS, the content-type seems to be application/octet-stream (the default one). So, in turn when getting used in the page, the svg content are not getting rendered in chrome and firefox, because the content-type is not image/svg+xml. We have to manually go and update the content type in the S3 bucket to image/svg+xml.
Any ideas, any hints to be tried?

We have already tried the following.
1. S3 bucket upload rules are forced to enforce image/svg+xml as content-type header for svg files. -- Still No luck.

  1. Ensure xml declarations are available on SVG file. -- Still no luck.

Thanks, Rams

3
  • "when the content is uploaded into S3 bucket of AWS" - how do you do that, is it a template or deployer extension? You can probably (I don't know for sure) set these properties at the time that the file gets pushed into S3.
    – Nuno Linhares
    Commented Sep 18, 2018 at 11:18
  • We use deployer to upload
    – Rams
    Commented Sep 18, 2018 at 12:39
  • Out of the box, Tridion doesn’t do this, so you must have an extension doing it. Find that (check deployer conf for module names, chances are one doesn’t start with com.tridion), find the code, change how it saves it to S3. stackoverflow.com/questions/23467044/…
    – Nuno Linhares
    Commented Sep 18, 2018 at 17:33

1 Answer 1

1

I have done something similar maybe this below reference code snippet might help you.

public static String getMimeType(String fileName) {
        FileNameMap fileNameMap = URLConnection.getFileNameMap();
        String mimeType = fileNameMap.getContentTypeFor(fileName);
        return mimeType;
    }

public void addBinaries(ConcurrentHashMap<String, BinaryIndexData> binaryAdds) throws AmazonClientException, IOException, ParserConfigurationException {

        getS3Client();

        if (amazonS3 == null)
        {
            throw new AmazonClientException("AWS server not instantiated.");
        }

        for (Map.Entry<String, BinaryIndexData> entry : binaryAdds.entrySet())
        {
            BinaryIndexData data = entry.getValue();

            LOG.debug("Dispatching binary content to AWS S3.");
            String fileName = data.getRelativePath();
            String contentType = Utils.getMimeType(data.getFileName());

            InputStream inputBinaryStream = new ByteArrayInputStream(data.getContent().getContent());
            ObjectMetadata objMeta = new ObjectMetadata();
            objMeta.setContentEncoding("UTF-8");
            objMeta.setContentLength(data.getContent().getContent().length);
            if (contentType != null) {
                objMeta.setContentType(contentType);
            }
           objMeta.addUserMetadata("tcmuri",data.getUniqueIndexId());

            if (amazonS3 != null) {
                amazonS3.putObject(new PutObjectRequest(
                        bucketName, fileName, inputBinaryStream, objMeta)
                        .withCannedAcl(CannedAccessControlList.PublicRead));
                LOG.info("addBinaryObject: Upload complete " + fileName);

            }
            else {
                LOG.error("addBinaryObject: Upload can't be done amazonS3 null " + fileName);
            }
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.