Giter Club home page Giter Club logo

Comments (7)

jedsundwall avatar jedsundwall commented on July 23, 2024

Thanks for this @kayaademogullari. We're looking into this!

from aws-js-s3-explorer.

john-aws avatar john-aws commented on July 23, 2024

Hi @kayaademogullari, please you could document the steps leading to this error, include the non-Latin names, and indicate exactly which code is generating the TypeError. Thanks.

from aws-js-s3-explorer.

kayaademogullari avatar kayaademogullari commented on July 23, 2024

I placed checkbox into renderObject function,

function renderObject(data, type, full) {
       /* if (isthisdocument(s3exp_config.Bucket, data)) {
            console.log("is this document: " + data);
            return fullpath2filename(data);
        } else */if (isfolder(data)) {
            console.log("is folder: " + data);
            return '<div class="block" id="' + data + '"><div class="img dir">&nbsp;</div><a data-s3="folder" data-prefix="' + data + '" href="' + object2hrefvirt(s3exp_config.Bucket, data) + '">' + prefix2folder(data) + '</a><p><input type="checkbox" class="messageCheckbox" name="' + data + '"id="' + data + '"value="' + data + '"></div>';

        } else {
            console.log("not folder/this document: " + data);
            return '<div class="block" id="' + data + '"><div class="img ' + uzant(data) + '">&nbsp;</div><a data-s3="object" href="' + object2hrefvirt(s3exp_config.Bucket, data) + '">' + fullpath2filename(data) + '</a><p><input type="checkbox" class="messageCheckbox" name="' + data + '"id="' + data + '"value="' + data + '"></div>';
        }
    }

Here uzant(data) is a function that get extension file name to affect block and add file or folder icon for Objects. And below I've defined a function for choosing Object with checkbox. When an Object is checked, we get its name and if we press the rename button, calls bootbox, trigger jQuery.rename function and asks for new name. If object name is Latin, we can add a new ANY name without problem, else copyObject property doesnt work and console gives us error, for example;

TypeError: Cannot convert string to ByteString because the character at index 23 has value 287 which is greater than 255.

getChecked = function () {
    var result = $('input[type="checkbox"]:checked');
    if (result.length > 0) {
        var choosenObj = "";
        result.each(function () {
            choosenObj = $(this).val();
            //filenameUnderFolder is a function that splits the path
            var utf_8_file = filenameUnderFolder(choosenObj); 
        });
        console.log(choosenObj);
        jQuery.rename = function () {
            bootbox.prompt({
                title: "Enter a name for your file",
                value: utf_8_file,
                callback: function (result) {
                    if (result === null) {
                        //nothing happens
                    } else {
                        var s3 = new AWS.S3();
                        var params = {
                            Bucket: 'myBucket',
                            CopySource: 'myBucket' + '/folder_a/' + utf_8_file,
                            Key: 'folder_b/' + result,
                            StorageClass: 'STANDARD_IA'
                        };
                        s3.copyObject(params, function (err, data) {
                            if (err) console.log(err);
                        });
                    }
                }
            });
        };
    } else {
        console.log('you choosed nothing.');
    }
};

The getChecked function above included copy, paste, move, delete, getpresignedUrl functions in jQuery as well like rename, and works clearly. Of course, copy, paste and move functions have same non-Latin name problem too.
By the way, I've convert s3.makeUnauthenticatedRequest to s3.makeRequest, sorry for mistake. After that, I can manipulate all of this via a new CognitoIdentityCredentials.

from aws-js-s3-explorer.

john-aws avatar john-aws commented on July 23, 2024

Hi, I was able to copy an object to another object with a non-Latin filename as follows:

var AWS = require("aws-sdk");

var s3 = new AWS.S3();

var params = {
    Bucket: 'mybucket',
    CopySource: 'myfolder/myfile.txt',
    Key: 'myfolder/myfile\u0287.txt'
};

s3.copyObject(params, function (err, data) {
    if (err) console.log(err);
});

from aws-js-s3-explorer.

kayaademogullari avatar kayaademogullari commented on July 23, 2024

Thank you very much.

from aws-js-s3-explorer.

kayaademogullari avatar kayaademogullari commented on July 23, 2024

Hi, I've solved the problem, changed CopySource parameter with encodeURI(file_name) property, like this;

                        var s3 = new AWS.S3();
                        var params = {
                            Bucket: 'myBucket',
                            CopySource: 'myBucket' + '/folder_a/' + encodeURI(utf_8_file),
                            Key: 'folder_b/' + result,
                            StorageClass: 'STANDARD_IA'
                        };
                        s3.copyObject(params, function (err, data) {
                            if (err) console.log(err);
                        });

thats all...

from aws-js-s3-explorer.

john-aws avatar john-aws commented on July 23, 2024

Good news, thanks for the update.

from aws-js-s3-explorer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.