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

Paths in filename while uploading a file is ignored #58

Open
warting opened this issue Dec 5, 2022 · 0 comments
Open

Paths in filename while uploading a file is ignored #58

warting opened this issue Dec 5, 2022 · 0 comments

Comments

@warting
Copy link

warting commented Dec 5, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant