I wrote the code to select and load an mp3 file, but I failed to store it as a String.
I need the mp3 file (very short, less than 5 seconds) as String to pass to an API who want String as parameter.
Ideas ?
I wrote the code to select and load an mp3 file, but I failed to store it as a String.
I need the mp3 file (very short, less than 5 seconds) as String to pass to an API who want String as parameter.
Ideas ?
open it as a binary stream and read the entire thing in
Store it in a MemoryBlock and send the StringValue to the API.
Damn: Norman was faster
Thank you guys, worsk fine.
Now I have in my Clipboard:
{{«class RTF », 3174}, {«class MPG3», 34056}}
An RTF text and a MP3 file
Picture and Text were lost in the process, more work to do.
If you read the whole file into a string there should be no loss… the string contains exactly the contents of the file, without any parsing/recognition, of course.
[code]Public Function FileToString(f as FolderItem) as String
'reads a file as BinaryStream
'and saves as string to be used in string field type
'no need for Blobs and fast
dim b as BinaryStream
dim data as String
b = BinaryStream.Open(f,false)
data = b.Read(b.length)
if b.ReadError then
ShowMessage(“Error reading file”)
return “”
end if
b.close
Return data
End Function
[/code]
Thank you Alexander for the code.
Mine was very basic, but looks similar (I do not needed the error checking, just basic stuff.
As I wrote earlier, this is a very small mp3 test file (37 KB).
Outch!
FOR TESTINGS
not for production
Sorry for the fear