Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UploadFile exception error: boundary #322

Open
YimingSun60 opened this issue Jan 13, 2025 · 0 comments
Open

UploadFile exception error: boundary #322

YimingSun60 opened this issue Jan 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@YimingSun60
Copy link

YimingSun60 commented Jan 13, 2025

Service

OpenAI

Describe the bug

I'm woring on a Unity project and trying to upload image using UploadFile, the image path is valid, but get the error: boundary
Weixin Screenshot_20250113150205

ArgumentException: boundary
System.Net.Http.MultipartContent..ctor (System.String subtype, System.String boundary) (at <6b7f3b30be4840f3b4c58acaa59bfe22>:0)
System.Net.Http.MultipartFormDataContent..ctor (System.String boundary) (at <6b7f3b30be4840f3b4c58acaa59bfe22>:0)
OpenAI.MultipartFormDataBinaryContent..ctor () (at <46f589334efd4b3886de60af8a780085>:0)
OpenAI.Files.InternalFileUploadOptions.ToMultipartContent (System.IO.Stream file, System.String filename) (at <46f589334efd4b3886de60af8a780085>:0)
OpenAI.Files.OpenAIFileClient.UploadFile (System.IO.Stream file, System.String filename, OpenAI.Files.FileUploadPurpose purpose, System.Threading.CancellationToken cancellationToken) (at <46f589334efd4b3886de60af8a780085>:0)
OpenAI.Files.OpenAIFileClient.UploadFile (System.String filePath, OpenAI.Files.FileUploadPurpose purpose) (at <46f589334efd4b3886de60af8a780085>:0)
OAVision.UploadImage (System.String imagePath, OpenAI.Files.OpenAIFileClient fileClient, OpenAI.Assistants.AssistantClient assistantClient) (at Assets/Scripts/OAVision.cs:48)
OAVision.SendImageToOpenAI (System.String imagePath) (at Assets/Scripts/OAVision.cs:35)
WebcamManager.OnStoppedPhotoMode (UnityEngine.Windows.WebCam.PhotoCapture+PhotoCaptureResult result) (at Assets/Scripts/WebcamManager.cs:44)
UnityEngine.Windows.WebCam.PhotoCapture.InvokeOnPhotoModeStoppedDelegate (UnityEngine.Windows.WebCam.PhotoCapture+OnPhotoModeStoppedCallback callback, System.Int64 hResult) (at :0)

Steps to reproduce

N/A

Code snippets

private void UploadImage(string imagePath, OpenAIFileClient fileClient, AssistantClient assistantClient)
{
    if (!File.Exists(imagePath))
    {
        Console.WriteLine("File not found: " + imagePath);
        return;
    }
    try
    {
        pictureOfUploadingFile = fileClient.UploadFile(imagePath, FileUploadPurpose.Vision);

        if (pictureOfUploadingFile != null && !string.IsNullOrEmpty(pictureOfUploadingFile.Id))
        {
            Console.WriteLine($"File uploaded successfully! File ID: {pictureOfUploadingFile.Id}");
            Console.WriteLine($"File Status: {pictureOfUploadingFile.Status}");
            Console.WriteLine($"Assistant has recieved the image");
            //ImageAssistant(pictureOfUploadingFile, assistantClient);
        }
        else
        {
            Console.WriteLine("File upload failed. The returned file object is null or incomplete.");
        }
    }
    catch (Exception ex) 
    {
        Debug.LogError($"An error occurred while uploading the file: {ex.Message}");
    }
}

OS

winOS11

.NET version

9.0.101

Library version

2.1.0

@YimingSun60 YimingSun60 added the bug Something isn't working label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant