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

Notification

Icon
Error

Options
Go to last post Go to first unread
DSCarl  
#1 Posted : Monday, July 17, 2006 9:34:36 PM(UTC)
DSCarl

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

File Attachment(s):
RenameUploaded Files.txt (2kb) downloaded 160 time(s).
Fedor  
#2 Posted : Monday, July 17, 2006 11:24:31 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,522

Thanks: 3 times
Was thanked: 52 time(s) in 51 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
DSCarl  
#3 Posted : Tuesday, July 18, 2006 2:45:36 AM(UTC)
DSCarl

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

Fedor  
#4 Posted : Wednesday, July 19, 2006 2:16:35 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,522

Thanks: 3 times
Was thanked: 52 time(s) in 51 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
DSCarl  
#5 Posted : Wednesday, July 19, 2006 10:45:29 PM(UTC)
DSCarl

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.
Users browsing this topic
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.