This question is locked. New answers and comments are not allowed.
Hello,
I am using the Q1 2012 release(2012.1.215.40)
I think I found an inconsistency with the file handling when OverwriteExistingFiles = True.
I am uploading 2 files to the same directory programmatically:
This would work the first time without issues, "First File" and "Second File" would be written to the server.
When I ran it again, I got an Access Denied error on "Second File".
I tried with just "First File" - no problem.
I tried just "Second File" - no problem.
I tried both files again - Access denied on "Second File".
I tried "Second" then "First" - Access denied on "First File".
I added a "Third File" - Access denied on "Second" and "Third".
All the files could be written the very first time, but only the first file in the list would succeed on any overwrite attempts.
So, in my handler I added an override of every single RadUploadHandler base method so I could trace what each file was doing.
It turns out that the first file uploaded will overwrite the existing file without first calling RadUploadHandler::RemoveFile() but subsequent files DO call it. If you only have Read/Write permissions on the folder, RemoveFile will fail so the file upload fails. Since the first file does not call RemoveFile it works just fine.
I worked around it by giving delete permission on the folder, but this seems unnecessary since I don't actually want to delete files, I just want to upload them. It also seems strange that the first file does not have this requirement.
Can you explain the reason for this?
Thanks.
I am using the Q1 2012 release(2012.1.215.40)
I think I found an inconsistency with the file handling when OverwriteExistingFiles = True.
I am uploading 2 files to the same directory programmatically:
Dim
objBytes
As
Byte
() = System.Text.Encoding.GetEncoding(
"UTF-8"
).GetBytes(
"This is file1"
)
Using objStream
As
New
System.IO.MemoryStream(objBytes)
Dim
uploadFile
As
New
RadUploadSelectedFile(objStream,
"First File"
)
Uploader.CurrentSession.SelectedFiles.Add(uploadFile)
End
Using
objBytes = System.Text.Encoding.GetEncoding(
"UTF-8"
).GetBytes(
"This is file2"
)
Using objStream
As
New
System.IO.MemoryStream(objBytes)
Dim
uploadFile
As
New
RadUploadSelectedFile(objStream,
"Second File"
)
Uploader.CurrentSession.SelectedFiles.Add(uploadFile)
End
Using
Uploader.PrepareSelectedFilesForUpload()
If
Uploader.CurrentSession.TotalFilesCount > 0
Then
Uploader.StartUpload()
End
If
This would work the first time without issues, "First File" and "Second File" would be written to the server.
When I ran it again, I got an Access Denied error on "Second File".
I tried with just "First File" - no problem.
I tried just "Second File" - no problem.
I tried both files again - Access denied on "Second File".
I tried "Second" then "First" - Access denied on "First File".
I added a "Third File" - Access denied on "Second" and "Third".
All the files could be written the very first time, but only the first file in the list would succeed on any overwrite attempts.
So, in my handler I added an override of every single RadUploadHandler base method so I could trace what each file was doing.
It turns out that the first file uploaded will overwrite the existing file without first calling RadUploadHandler::RemoveFile() but subsequent files DO call it. If you only have Read/Write permissions on the folder, RemoveFile will fail so the file upload fails. Since the first file does not call RemoveFile it works just fine.
I worked around it by giving delete permission on the folder, but this seems unnecessary since I don't actually want to delete files, I just want to upload them. It also seems strange that the first file does not have this requirement.
Can you explain the reason for this?
Thanks.