Skip to content

Paths in filename while uploading a file is ignored #58

@warting

Description

@warting

We are using the file upload API:s to upload our translations
https://github.com/onesky/api-documentation-platform/blob/master/resources/file.md#upload---upload-a-file

We need to use paths in the filename to be able to upload multiple strings.xml files.

But if we upload the files with the name foo/strings.xml onesky is saving it as strings.xml.

We use retrofit and have the endpoint set up like this:

val file : File = File("foo/strings.xml")
val part = MultipartBody.Part.createFormData("file", "foo/strings.xml", file.asRequestBody())

@Multipart
@POST("projects/{projectId}/files")
suspend fun uploadFile(
    @Path("projectId") projectId: Int,
    @Part() file: MultipartBody.Part,
    @Query("is_keeping_all_strings") keepAllStrings: Boolean,
    @Query("file_format") fileFormat: String = "ANDROID_XML",
): Response<UploadResponseBody>

Inspecting the request in an interceptor the part looks like
Content-Disposition: form-data; name="file"; filename="foo/strings.xml"

Response is:


response is:
{
 "meta": {
   "status": 201
 },
 "data": {
   "name": "strings.xml",
   "format": "ANDROID_XML",
   "language": {
     "code": "en",
     "english_name": "English",
     "local_name": "English",
     "custom_locale": null,
     "locale": "en",
     "region": ""
   },
   "import": {
     "id": 14178474,
     "created_at": "2022-12-05T11:55:08+0000",
     "created_at_timestamp": 1670241308
   }
 }
}

How can we set the full path while uploading a file through the API:s? It seems to be possible to manually rename the file string.xml to foo/string.xml in onesky's website.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions