Aurigma Forums
»
Upload Suite
»
Discussions – ActiveX/Java Uploader
»
How to rename uploaded files in ImageUploader 4.0 when using the Concurrent upload process
Rank: Member
Groups: Member
Joined: 4/25/2006(UTC) Posts: 61
|
Hello, I am trying to rename files/images during the upload process in ImageUploader 4.0 using the concurrent upload process. In my Default.aspx page, I have FilesPerOnePackageCount set to 1 (u.addParam("FilesPerOnePackageCount", "1")I am having difficulties doing this because of the way the Concurrent Method process files. Please, help on this. Note1: I was able to rename files when using ImageUploader 3.5 as shown in the blog of code below. Also, please take a look at the attached document and let me know if you need more code or explanation to help you better understand my problem. Note2: The SyncLock(Application) method is used in Concurrent Upload Code:<%@ Page Language="VB" AutoEventWireup="false" ValidateRequest="false" %>
<script runat="server">
'This variable specifies relative path to the folder, where the gallery
'with uploaded files is located.
Private galleryPath As String = "../Gallery/"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Get total number of uploaded files (all files are uploaded in a single package).
Dim fileCount As integer = Int32.Parse(Request.Form("FileCount"))
'Iterate through uploaded data and save the original file and thumbnail
For I As Integer = 1 To fileCount
'Get source file and save it to disk.
Dim sourceFile As HttpPostedFile = Request.Files("SourceFile_" & I)
Dim fileName As String = System.IO.Path.GetFileName(sourceFile.FileName)
sourceFile.SaveAs(Server.MapPath(galleryPath & fileName))
'Get first thumbnail (the single thumbnail in this code sample) and save it to disk.
Dim thumbnail1File As HttpPostedFile = Request.Files("Thumbnail1_" & I)
[i][b]thumbnail1File.SaveAs(Server.MapPath(galleryPath & "Thumbnails/" & fileName & ".jpg")) [/i][/b][b]//File was renamed with .jpg[/b]
Next
End Sub
</script>
How can I do something similar to the above code in ImageUploader 4.0 using the Concurrent Upload process? Thanks in advance. Edited by user Monday, February 18, 2008 6:37:17 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Have you checked Concurrent Upload sample from Image Uploader 4.0 evaluation package?
Doesn't it do what you need? |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/25/2006(UTC) Posts: 61
|
No, I don't think so. It does not do what I need. Using the Basic Sample, I can rename the uploaded files sequentially using the code below.. Code:Dim intFileCount As Integer = CInt(Request.Form("PackageCount"))
For I = 1 To intFileCount
Dim StrFileName As String = Path.GetFileName(SourceFile.FileName) & "-" & I & ".jpg"
Next
I think my difficulties is due to the fact that this file is used by different upload threads asynchronously;hence, the SyncLock(Application) block is used. You see, my main focus here is being able to use this For loop in Sequentially re-naming the uploaded files. Hope you get my point. If not, please, let me know. Thanks. DSCarl. Edited by user Wednesday, December 19, 2007 3:59:38 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
In order to rename files sequentially all at once you should have all files to be already uploaded.
However when or with what package index should we do it?
On first glance we should rename files when we receive request PackageIndex==PackageCount-1, however request with PackageIndex==PackageCount-1 can be uploaded on server BEFORE one with PackageIndex==PackageCount-2 due concurrent nature of upload.
I think the easiest solution is to rename separately each file. |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/25/2006(UTC) Posts: 61
|
Hello,
Thanks for the reply. I will stick then to obtaining all files before sequentially renaming the files.
Regards, DSCarl.
|
|
|
|
Aurigma Forums
»
Upload Suite
»
Discussions – ActiveX/Java Uploader
»
How to rename uploaded files in ImageUploader 4.0 when using the Concurrent upload process
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.