Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
zhenl  
#1 Posted : Monday, January 24, 2011 8:16:27 PM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Hello,

I'm testing the 7.0.15 and want to migrate our application from 6.5 to it. The application allows user to upload original image and two thumbnail images to s3. All works fine but I cannot find a way to remove the _Thumbnail.jpg from the thumbnail image name. In version 6.5, we can use u.addField("key", folder + sourceName); in packagebeforeupload event. But it seems not to work with the 7.0.15.

Regards

Lei

Dmitry.Obukhov  
#2 Posted : Tuesday, January 25, 2011 12:36:32 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Lei,

API of Image Uploader 7 is not the same as API of Image Uploader 6. Now you need use key property like in this code snippet:

Code:
 as3.converters( [
        {
            //...other params...
            key: "${filename}",
            //...other params...
        }
    ]
})

You are able to find details of new API in our documentation.

Please let me know if you have any questions.

Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

zhenl  
#3 Posted : Tuesday, January 25, 2011 1:12:44 AM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Hello Dmitry,

Thanks for your reply.

I've set the key in behide code. Could you please help to see if there are errors in below code? The code can work but the files uploaded in S3 with the _Thumbnail0.jpg.

Code:
imgUploader.LicenseKey = LicenseKey 
            imgUploader.UploadSettings.ActionUrl = Me.Request.RawUrl
            Dim c As New Converter

            If Not Null.IsNull(MaxImageWidth) Then
                c.Mode = "*.*=Thumbnail"
                c.ThumbnailWidth = MaxImageWidth
                c.ThumbnailFitMode = ThumbnailFitMode.Fit
                c.ThumbnailHeight = MaxImageWidth * 4
                c.ThumbnailResizeQuality = Aurigma.ImageUploader.ResizeQuality.High
                c.ThumbnailJpegQuality = Me.ResizeQuality
            Else
                c.Mode = "*.*=SourceFile"
            End If

            imgUploader.Converters.Add(c)
            imgUploader.Height = Me.Controlheight
            imgUploader.FolderPane.Height = CType(Me.Controlheight / 2, Integer)

            c = New Converter
            c.Mode = "*.*=Thumbnail"
            c.ThumbnailWidth = ThumbnailImageWidth
            c.ThumbnailFitMode = ThumbnailFitMode.Fit
            c.ThumbnailHeight = ThumbnailImageWidth * 4
            c.ThumbnailResizeQuality = Aurigma.ImageUploader.ResizeQuality.High
            c.ThumbnailJpegQuality = Me.ThumbnailQuality
            imgUploader.Restrictions.MaxFileCount = Me.EachTimeUploader
            imgUploader.Restrictions.MaxFileSize = Me.EachTimeFileSize
            AmazonS3Extender1.TargetControlID = "imgUploader"

            AmazonS3Extender1.SecretAccessKey = Me.S3SecurityKey
            AmazonS3Extender1.AWSAccessKeyId = Me.S3AccessKey
            AmazonS3Extender1.Bucket = Me.S3Bluk

            Dim fs As New Aurigma.ImageUploader.AmazonS3.FileSettings
            fs.Acl = "public-read"
            fs.Key = Me.S3Folder & "original/${filename}"
            AmazonS3Extender1.Files.Add(fs)

            Dim fs1 As New Aurigma.ImageUploader.AmazonS3.FileSettings
            fs1.Acl = "public-read"
            fs1.Key = Me.S3Folder & "thumb/${filename}"
            AmazonS3Extender1.Files.Add(fs1)

Thanks

Lei

Edited by moderator Tuesday, January 25, 2011 1:39:16 AM(UTC)  | Reason: Not specified

Dmitry.Obukhov  
#4 Posted : Tuesday, January 25, 2011 2:56:43 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Lei,

Unfortunately, I am not savvy in upload to Amazon S3. I discussed your problem with our engineer. Actually, changing thumbnail names is impossible in upload to Amazon storage, and the way you implemented in your script is incorrect to avoid it. You may try this workaround.

You are able to use BeforeSendRequest event where you need to add custom filed like with Image Uploader 6.5:

Code:
u.addCustomField('key',  Folder  + SourceName);

Please note, you should call this event after AmazonS3 extender.

It should work okay if you upload the both converters to the same folder.

According to your script listed above, you upload source files and thumbnails in different folders. You need to implement some script, which allow separating these converters to different folders, e.g. the first uploaded file is source file and should be saved in origin/ folder, the second one is thumbnail and should be saved in thumb/ folder, etc. That it files with odd numbers are saved in origin/, even ones are saved in thumb/.

If something is unclear, please let us know.

Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

zhenl  
#5 Posted : Tuesday, January 25, 2011 6:22:55 PM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Hello Dmitry

Thanks for your reply. However it does not work. I add event to BeforeSendRequest as below:

Code:
function beforeSendRequest() {

    var u = $au.uploader(IMAGE_UPLOADER_ID);
    var Folder = "";
    if (uc == 0) {
        Folder = "original/";
        uc = 1;
    }
    else {
        Folder = "thumb/";
        uc = 0;
    }
    var f = u.files().get(uploadCount);
    var SourceName=f.name();
   
    u.metadata().addCustomField('key', Root + Folder + SourceName );
   
}

But the files are still saved to the path that defined in AmazonS3 extender and with _Thumbnail in the filename.

Any ideas?

Regards

Lei

Edited by moderator Tuesday, February 1, 2011 12:27:40 AM(UTC)  | Reason: Not specified

andreym  
#6 Posted : Wednesday, January 26, 2011 10:54:17 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello Lei

Your beforeSendRequest function looks fine and it should work. But the main point of the workaround is the beforeSendRequest handler should be added after the AmazonS3Extened handler. And we need to do some work to get it done:

1. Override PreRenderComplete method of the page with Image Uploader ASP.NET control in the server-side code.

Code:
protected override void OnPreRenderComplete(EventArgs e)
{
	base.OnPreRenderComplete(e);
	Uploader1.ClientEvents.Add(new ClientEvent(
		ClientEventNames.PreRender, "onPreRender"));
}

2. Add onPreRender event handler in the client-side code and add beforeSendRequest event handler from it.

Code:
function onPreRender() {
	this.events().beforeSendRequest().add(onBeforeSendRequest);
}

3. In the onBeforeSendRequest function use addCustomField method to add key field with file name value.

Code:
var i = 0;
var folders = [
	'ImageUploader7/small/',
	'ImageUploader7/large/',
	'ImageUploader7/original/'
];
function onBeforeSendRequest() {
	var fileName = this.files().get(0).name();
	this.metadata().addCustomField('key', folders[i] + fileName);
	i = (i + 1) % 3;
}

Note, that my onBeforeSendRequest expect, that 3 converters are used.

If you upload only 2 then change last line to i = (i + 1) % 2; and remove last element from folders array.

Hope it helps.

thanks 1 user thanked andreym for this useful post.
zhenl on 1/27/2011(UTC)
zhenl  
#7 Posted : Thursday, January 27, 2011 12:40:53 AM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Hello,

Thanks for your help. Unfortunately it still does not work. All files are uploaded to the path set in AmazonS3Extened file settings and with the _Thumbnail. I attached the generated HTML in this ticket. May be it can help you to find the issue.

Thanks

Lei

File Attachment(s):
UploaderNotWork.zip (13kb) downloaded 4 time(s).
andreym  
#8 Posted : Thursday, January 27, 2011 1:55:04 AM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello!

Looked at you attached file and the order of the preRender event handlers is wrong:

Code:
preRender: [ onPreRender, function() {var u = this, as3 = new $au.amazonS3Extender(u);...}] }

onPreRender function should be after. Can you please post your VB.NET code? And also check that you add PreRender event in the OnPreRenderComplete function.

thanks 1 user thanked andreym for this useful post.
zhenl on 1/27/2011(UTC)
zhenl  
#9 Posted : Thursday, January 27, 2011 5:34:33 PM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Thanks for your help. It works now. I should add the code in the page event OnPreRenderComplete event.

However I met two issues when I tested it in Java version. Both are not in ActiveX version. Maybe they are known issues.

1. The file extension is lost.

2. If uploading several files one time, the last one cannot be uploaded. For example, if I upload two photos, only the first one is uploaded. If I uploaded four photos, only the first three photos are uploaded.

Thanks again for your great support.

Lei

Dmitry.Obukhov  
#10 Posted : Friday, January 28, 2011 4:14:58 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hi Lei,

  1. Quote:
    The file extension is lost.

    It is a known issue of Java version. name property like in the script:

    Code:
     
    …
    var fileName = this.files().get(0).name(); 
    …

    returns just name of file without its extension. It will be fixed in the next minor release of Image Uploader 7. Sorry for this.

    As a workaround, you can add file extinction to its name like in the code:

    Code:
    function onBeforeSendRequest() {
        var fileName = this.files().get(0).name();
        this.metadata().addCustomField('key', folders[i] + filename + “.jpg”);
        i = (i + 1) % 3;
    }

  2. Quote:
    If uploading several files one time, the last one cannot be uploaded. For example, if I upload two photos, only the first one is uploaded. If I uploaded four photos, only the first three photos are uploaded.

    This problem is very strange. Could you please test it uploading files to local server, not to AmazonS3? And then let us know whether the problem occurs locally. Also, please provide us with Image Uploader configuration.

Looking forward to your reply.

Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

thanks 1 user thanked Dmitry.Obukhov for this useful post.
zhenl on 1/28/2011(UTC)
zhenl  
#11 Posted : Friday, January 28, 2011 4:31:00 AM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Hello Dmitry,

I'll test it and tell you the result.

Regards

Lei

zhenl  
#12 Posted : Saturday, January 29, 2011 5:01:53 PM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Hello Dmitry,

The issue only occurs when I try to keep the filename when uploading to s3. If I remove the script of changing filename, it can work properly in FireFox(java version). However in my case it will lose the last file when uploading several files by using Firefox(java version). I attached two html files here. One has no javascript code and can upload all files. The other has javascript code to keep filename but will lose last file.

Thanks

Lei

File Attachment(s):
UnzipIt.zip (26kb) downloaded 5 time(s).
andreym  
#13 Posted : Monday, January 31, 2011 3:26:28 AM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello Lei.

Ok, I think I found the cause of this problem. It is the multithreading :-)

When Image Uploader create packages, it creates them in different thread from the package will be uploaded. So there is no guarantee, that the first file in the upload pane is the file, for which BeforeSendRequest event occurred. And if so, it may take the file name of the wrong file and upload different files with the same name.

The solution is simple. Save all file names in BeforeUpload event handler:

Code:
var files;
function onBeforeUpload() {
	var count = u.files().count();
	files = [];
	i = 0;
	for (var j = 0; j < count; j++) {
		var f = u.files().get(i);
		files.push('ImageUploader7/small/' + f.name());
		files.push('ImageUploader7/large/' + f.name());
	}
}

And use them in BeforeSendRequest event handler:

Code:
function onBeforeSendRequest() {
	var fileName = files[i];
	this.metadata().addCustomField('key', fileName);
	i++;
}
thanks 1 user thanked andreym for this useful post.
zhenl on 1/31/2011(UTC)
zhenl  
#14 Posted : Monday, January 31, 2011 4:30:43 AM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
Great! I'll try it soon. Thank you very much.
zhenl  
#15 Posted : Monday, January 31, 2011 4:10:59 PM(UTC)
zhenl

Rank: Member

Groups: Member
Joined: 10/16/2009(UTC)
Posts: 23

Thanks: 4 times
It works! Thanks again. Looking forward to your next version that will fix the file extension issue.
Dmitry.Obukhov  
#16 Posted : Monday, January 31, 2011 11:15:38 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Lei,

Thank you for your comments. We are glad that the problem has been resolved :)

I will let you know as soon as the next update of Image Uploader 7 will be released. If you have any questions, please post them here.

Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.